Filter function to apply to each element of range (optional)
Map function to apply to each element of range
rcfilter!(pred)(range) returns a new RCArray containing only elements map(x) in range for which pred(x) returns true.
import mir.ndslice.topology: iota; auto val = 3; auto factor = 5; // Filter iota 2x3 matrix below 3 assert(iota(2, 3).rcfilter!(a => a < val).moveToSlice.equal(val.iota)); // Filter and map below 3 assert(6.iota.rcfilter!(a => a < val, a => a * factor).moveToSlice.equal(val.iota * factor));
Implements the higher order filter and map function. The predicate and map functions are passed to mir.functional.naryFun, and can either accept a string, or any callable that can be executed via pred(element) and map(element).