One or more functions.
Returns RCArray for input ranges and one-dimensional slices.
import mir.algorithm.iteration: filter, equal; auto factor = 10; auto step = 20; assert (3.iota.rcmap!(a => a * factor).moveToSlice.equal(3.iota * factor)); assert (6.iota.filter!"a % 2".rcmap!(a => a * factor).moveToSlice.equal([3].iota(factor, step)));
For multidimensional case returns Slice!(RCI!T, N).
import mir.ndslice.topology : iota; auto factor = 3; auto s = iota(2, 3).rcmap!(a => a * factor); assert(s == iota(2, 3) * factor);
String lambdas
import mir.ndslice.topology : iota; assert(iota(2, 3).rcmap!"a * 2" == iota(2, 3) * 2);
Implements the homonym function (also known as transform) present in many languages of functional flavor. The call rmap!(fun)(slice) returns an RC array (1D) or RC slice (ND) of which elements are obtained by applying fun for all elements in slice. The original slices are not changed. Evaluation is done eagerly.
Note: transposed and pack can be used to specify dimensions.