An array to be sliced.
With a binary predicate, a range of slices is returned in which predicate holds for every pair of adjacent elements in a given slice.
import dalicious.math : absdiff; import std.algorithm.comparison : equal; // Chain elements that are not too far apart auto data = [1, 2, 3, 2, 1, 8, 5, 6, 7]; auto r1 = data.chainBy!((a, b) => absdiff(a, b) <= 1); assert(r1.equal([ data[0 .. 5], data[5 .. 6], data[6 .. 9], ]));
Create chains of items linked by areChainable. This similar to sliceBy but areChainable does not have to be an equivalence relation.