The OpenD Programming Language

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.

template eachOnBorder(alias fun)
static if(__traits(isSame, naryFun!fun, fun))
void
eachOnBorder
(
Slices...
)
(
Slices slices
)
if ()

Members

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