The OpenD Programming Language

mir_slice.opBinary

Element-wise operator overloading for slices.

  1. auto opBinary(T value)
  2. auto opBinary(Slice!(RIterator, RN, rkind) rhs)
    struct mir_slice(Iterator_, size_t N_ = 1, SliceKind kind_ = Contiguous, Labels_...)
    return scope
    opBinary
    (
    string op
    RIterator
    size_t RN
    SliceKind rkind
    )
    (
    scope return Slice!(RIterator, RN, rkind) rhs
    )
    if (
    N == RN &&
    (
    rkind == Contiguous
    ||
    N == 1
    )
    &&
    op != "~"
    )
    if (
    0 < N_ &&
    N_ < 255
    &&
    !(
    kind_ == Canonical &&
    N_ == 1
    )
    &&
    Labels_.length <= N_
    &&
    isIterator!Iterator_
    )

Parameters

rhs Slice!(RIterator, RN, rkind)

a slice of the same shape.

Return Value

Type: auto

lazy slice the same shape that has Contiguous kind Note: Binary operator overloading is allowed if both slices are contiguous or one-dimensional.
Does not allocate neither new slice nor a closure.

Examples

import mir.ndslice.topology: iota, map, zip;

auto s = iota([2, 3]);
auto c = iota([2, 3], 5, 8);
assert(s * s + c == s.map!"a * a".zip(c).map!"a + b");

Meta