The OpenD Programming Language

ndiota

Returns a slice, the elements of which are equal to the initial multidimensional index value. For a flattened (contiguous) index, see iota.

ndiota
(
size_t N
)
(
size_t[N] lengths...
)
if (
N
)

Parameters

N

dimension count

lengths size_t[N]

list of dimension lengths

Return Value

Type: Slice!(FieldIterator!(ndIotaField!N), N)

N-dimensional slice composed of indices

Examples

auto slice = ndiota(2, 3);
static immutable array =
    [[[0, 0], [0, 1], [0, 2]],
     [[1, 0], [1, 1], [1, 2]]];

assert(slice == array);
auto im = ndiota(7, 9);

assert(im[2, 1] == [2, 1]);

//slicing works correctly
auto cm = im[1 .. $, 4 .. $];
assert(cm[2, 1] == [3, 5]);

See Also

Meta