Phobos lacks a particular family of range functions...

Basile B. via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Oct 21 12:41:00 PDT 2016


They would have for constraint

   `if (isInputRange!Range && isInputRange!(ElementType!Range))`

In case you wouldn't see directly what would they be used for, 
it's for tree-like structures. Each element in a Range is also an 
input range.

I see 3 obvious functions/templates

- the most important, make an input range from a tree-like range, 
e.g `auto treeRange(Range, DepthMode mode)(Range range) `

- a second version for bidir ranges, e.g `reverseTreeRange`

- a functional iteration algorithm: auto `deepIterate(alias Fun, 
DepthMode mode, Range, A...)(Range range, auto ref A a)`, which 
applies Fun to each element with the ability for Fun to act as a 
predicates to stop the iteration. Actually I have this one in my 
user library (this is also the reason why I post this today).

Unless I'm blind I cannot see anything that handles trees with a 
range interface in phobos.


More information about the Digitalmars-d-learn mailing list