19 Sep
2005
19 Sep
'05
3:26 p.m.
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