For Chuck Allison: possible homework in D

FreeSlave via Digitalmars-d digitalmars-d at puremagic.com
Sun Jun 8 03:51:06 PDT 2014


The good exercise would be implementing some traversal (walk) 
algorithms for the generic tree structures. There are many tree 
traversal algorithms (some kinds of depth search and 
breadth-first search) and they may have range interface, so you 
can use them just like other ranges and don't need to write 
treeMap or treeFilter, because generic algorithms are already 
suitable with ranges.

It may look like this:

foreach(node; tree.byBreadth) // byDepth. Maybe it needs some 
more convenient names.
{
    //use node
}

It's good way to show how D range concept is generic.


More information about the Digitalmars-d mailing list