chopped

Maps index pairs to subslices.

  1. Slice!(ChopIterator!(Iterator, Sliceable)) chopped(Sliceable sliceable, Slice!Iterator bounds)
    @optmath
    Slice!(ChopIterator!(Iterator, Sliceable))
    chopped
    (
    Iterator
    Sliceable
    )
    (
    Sliceable sliceable
    ,
    Slice!Iterator bounds
    )
  2. auto chopped(Sliceable sliceable, S[] bounds)
  3. auto chopped(Sliceable sliceable, S bounds)

Parameters

bounds Slice!Iterator

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: Slice!(ChopIterator!(Iterator, Sliceable))

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