The OpenD Programming Language

mir_slice.backward

Convenience function for backward indexing.

  1. auto ref backward(size_t[N] index)
  2. auto ref backward(size_t[N] index)
  3. auto ref backward(size_t[N] index)
    struct mir_slice(Iterator_, size_t N_ = 1, SliceKind kind_ = Contiguous, Labels_...)
    ref return scope const
    backward
    ()
    (
    size_t[N] index
    )
    if (
    0 < N_ &&
    N_ < 255
    &&
    !(
    kind_ == Canonical &&
    N_ == 1
    )
    &&
    Labels_.length <= N_
    &&
    isIterator!Iterator_
    )

Return Value

Type: auto ref

this[$-index[0], $-index[1], ..., $-index[N-1]]

Examples

import mir.ndslice.topology : iota;
auto s = iota(2, 3);
assert(s[$ - 1, $ - 2] == s.backward([1, 2]));

Meta