Slides from LASER 2012

bearophile bearophileHUGS at lycos.com
Thu Sep 20 14:33:42 PDT 2012


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).dynRange

Maybe a "~" operator can be defined for such dynRanges, to avoid 
the chain().

Bye,
bearophile


More information about the Digitalmars-d-announce mailing list