The OpenD Programming Language

chopped

Maps index pairs to subslices.

Parameters

bounds S

ndslice composed of consequent (a_i <= a_(i+1)) pairwise index bounds.

sliceable Sliceable

pointer, array, ndslice, series, or something sliceable with [a_i .. a_(i+1)].

Return Value

Type: auto

ndslice composed of subslices.

Examples

import mir.functional: staticArray;
import mir.ndslice.slice: sliced;
auto pairwiseIndexes = [2, 4, 10].sliced;
auto sliceable = 10.iota;

auto r = sliceable.chopped(pairwiseIndexes);
assert(r == [
    iota([4 - 2], 2),
    iota([10 - 4], 4),
    ]);

See Also

Meta