a slice or an array to iterate over
triplets(eeeeee) => ||c|lllll| |r|c|llll| |rr|c|lll| |rrr|c|ll| |rrrr|c|l| |rrrrr|c||
import mir.ndslice.slice: sliced; import mir.ndslice.topology: triplets, member, iota; auto a = [4, 5, 2, 8]; auto h = a.triplets; assert(h[1].center == 5); assert(h[1].left == [4]); assert(h[1].right == [2, 8]); h[1].center = 9; assert(a[1] == 9); assert(h.member!"center" == a); // `triplets` topology can be used with iota to index a slice auto s = a.sliced; auto w = s.length.iota.triplets[1]; assert(&s[w.center] == &a[1]); assert(s[w.left].field is a[0 .. 1]); assert(s[w.right].field is a[2 .. $]);
Constructs a lazy view of triplets with left, center, and right members.