The OpenD Programming Language

ipack

Creates a packed slice, i.e. slice of slices. Packs the last N - P dimensions. The function does not allocate any data.

Slice!(SliceIterator!(Iterator, N - P,
N - P == 1 &&
kind == Canonical
? Contiguous : kind), P, Universal)
ipack
(
size_t P
Iterator
size_t N
SliceKind kind
)
(
Slice!(Iterator, N, kind) slice
)
if (
P &&
P < N
)

Parameters

slice Slice!(Iterator, N, kind)

a slice to pack

Examples

import mir.ndslice.slice: sliced, Slice;

auto a = iota(3, 4, 5, 6);
auto b = a.ipack!2;

static immutable res1 = [3, 4];
static immutable res2 = [5, 6];
assert(b.shape == res1);
assert(b[0, 0].shape == res2);
assert(a.ipack!2 == b);
static assert(is(typeof(b) == typeof(a.ipack!2)));

See Also

Meta