Timon Gehr:
mixin ADT!q{ Tree(T): Leaf(T x), Node(Tree a, Tree b) };DynRange!T fringe(T)(Tree!T t){ return t.match!( (Leaf l) => cons(l.x, empty), (Node n) => chain(n.a.fringe, n.b.fringe).dynRange, ); } bool sameFringe(T)(Tree!T t1, Tree!T t2){ return equal(t1.fringe, t2.fringe); }
What's the purpose of the dynRange suffix here? (Node n) => chain(n.a.fringe, n.b.fringe).dynRangeMaybe a "~" operator can be defined for such dynRanges, to avoid the chain().
Bye, bearophile