The OpenD Programming Language

sliced

Creates an n-dimensional slice-shell over the 1-dimensional input slice.

  1. auto sliced(Iterator iterator, size_t[N] lengths)
  2. Slice!(T*) sliced(T[] array)
  3. Slice!(Iterator, N, kind) sliced(Slice!(Iterator, 1, kind) slice, size_t[N] lengths)
    Slice!(Iterator, N, kind)
    sliced
    (
    Iterator
    size_t N
    SliceKind kind
    )
    (
    Slice!(Iterator, 1, kind) slice
    ,
    size_t[N] lengths...
    )
    if (
    N
    )

Parameters

slice Slice!(Iterator, 1, kind)

slice

lengths size_t[N]

A list of lengths for each dimension.

Return Value

Type: Slice!(Iterator, N, kind)

n-dimensional slice

Examples

import mir.ndslice.topology : iota;
auto data = new int[24];
foreach (i, ref e; data)
    e = cast(int)i;
auto a = data[0..10].sliced(10)[0..6].sliced(2, 3);
auto b = iota!int(10)[0..6].sliced(2, 3);
assert(a == b);
a[] += b;
foreach (i, e; data[0..6])
    assert(e == 2*i);
foreach (i, e; data[6..$])
    assert(e == i+6);

Meta