The OpenD Programming Language

maxPos

Finds a backward index such that slice.backward(index) is minimal(maximal).

Parameters

pred

A predicate.

Examples

import mir.ndslice.slice: sliced;
auto s = [
    2, 6, 4, -3,
    0, -4, -3, 3,
    -3, -2, 7, 2,
    ].sliced(3, 4);

auto pos = s.minPos;

assert(pos == s[$ - 2 .. $, $ - 3 .. $]);
assert(pos.first == -4);
assert(s.backward(pos.shape) == -4);

pos = s.maxPos;

assert(pos == s[$ - 1 .. $, $ - 2 .. $]);
assert(pos.first == 7);
assert(s.backward(pos.shape) == 7);

See Also

Meta