[Haskell-cafe] Tree Construction
sjoerd at w3future.com
Sat Sep 25 09:14:59 EDT 2010
I think what you need is a trie. See f.e. http://hackage.haskell.org/package/list-tries
On Sep 25, 2010, at 11:54 AM, Tom Hawkins wrote:
> Often I need to assemble a tree from things with unstructured
> hierarchical paths. I built a function  to do this for ImProve.
> But does a library already exist that does this? If not I may create
> one, as I need it for a few different libraries.
> data Tree a b = Branch a [Tree a b] | Leaf a b
> tree :: (Eq a, Ord a) => (b -> [a]) -> [b] -> [Tree a b]
> Note, type 'a' is some sort of label, most often a string, and type
> 'b' form the leaves of the tree. The function passed into 'tree'
> returns the hierarchical path of a leaf object.
>  http://hackage.haskell.org/packages/archive/improve/0.0.12/doc/html/Language-ImProve-Tree.html
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
More information about the Haskell-Cafe