In this case, I think all you need is:

> type Path = [String]

> allPaths :: Path -> Tree -> [Path]
> allPaths p (Node s []) = [s:p]
> allPaths p (Node s subTrees) = concatMap (allPaths (s:p)) subTrees

> paths = map reverse . allPaths []

In your test case, "root" will be at the beginning of each path
produced, but you can map tail over the list if you don't want it.

 /g
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to