eachOnBorder

The call each!(fun)(slice1, ..., sliceN) evaluates fun for each set of elements x1, ..., xN in the borders of slice1, ..., sliceN respectively.

each allows to iterate multiple slices in the lockstep.

  1. void eachOnBorder(Slices slices)
    template eachOnBorder(alias fun)
    @optmath
    static if(__traits(isSame, naryFun!fun, fun))
    @optmath
    void
    eachOnBorder
    (
    Slices...
    )
    (
    Slices slices
    )
    if (
    allSatisfy!(isSlice, Slices)
    )
  2. alias eachOnBorder = .eachOnBorder!(naryFun!fun)

Members

Aliases

eachOnBorder
alias eachOnBorder = .eachOnBorder!(naryFun!fun)
Undocumented in source.

Functions

eachOnBorder
void eachOnBorder(Slices slices)

Parameters

fun

A function. Note: $(NDSLICEREF dynamic, transposed) and $(NDSLICEREF topology, pack) can be used to specify dimensions.

Examples

import mir.ndslice.allocation : slice;
import mir.ndslice.topology : repeat, iota;

auto sl = [3, 4].iota.slice;
auto zeros = repeat(0, [3, 4]);

sl.eachOnBorder!"a = b"(zeros);

assert(sl == 
    [[0, 0, 0 ,0],
     [0, 5, 6, 0],
     [0, 0, 0 ,0]]);

sl.eachOnBorder!"a = 1";
sl[0].eachOnBorder!"a = 2";

assert(sl == 
    [[2, 1, 1, 2],
     [1, 5, 6, 1],
     [1, 1, 1 ,1]]);

Meta