The OpenD Programming Language

evertPack

Reverses the order of dimension packs. This function is used in a functional pipeline with other selectors.

Slice!(SliceIterator!(Iterator, N, outerKind), M, innerKind)
evertPack
(
Iterator
size_t M
SliceKind innerKind
size_t N
SliceKind outerKind
)
(
Slice!(SliceIterator!(Iterator, M, innerKind), N, outerKind) slice
)

Parameters

slice Slice!(SliceIterator!(Iterator, M, innerKind), N, outerKind)

packed slice

Return Value

Type: Slice!(SliceIterator!(Iterator, N, outerKind), M, innerKind)

packed slice

Examples

import mir.ndslice.dynamic : transposed;
auto slice = iota(3, 4, 5, 6, 7, 8, 9, 10, 11).universal;
assert(slice
    .pack!2
    .evertPack
    .unpack
         == slice.transposed!(
            slice.shape.length-2,
            slice.shape.length-1));
import mir.ndslice.iterator: SliceIterator;
import mir.ndslice.slice: sliced, Slice, Universal;
import mir.ndslice.allocation: slice;
static assert(is(typeof(
    slice!int(6)
        .sliced(1,2,3)
        .pack!1
        .evertPack
    )
     == Slice!(SliceIterator!(int*, 2, Universal), 1)));
auto a = iota(3, 4, 5, 6, 7, 8, 9, 10, 11);
auto b = a.pack!2.unpack;
static assert(is(typeof(a.canonical) == typeof(b)));
assert(a == b);

See Also

Meta