List rooted trees: Difference between revisions
Content added Content deleted
(→{{header|Haskell}}: Defined commasFromTree in terms of Data.Tree.foldTree) |
(→{{header|Haskell}}: (added implementation of foldTree for versions of Data.Tree that lack it)) |
||
Line 429: | Line 429: | ||
(1 + foldr ((+) . rootLabel) 0 xs) |
(1 + foldr ((+) . rootLabel) 0 xs) |
||
(sortBy (flip (comparing rootLabel)) xs) |
(sortBy (flip (comparing rootLabel)) xs) |
||
--foldTree :: (a -> [b] -> b) -> Tree a -> b |
|||
--foldTree f = go where |
|||
-- go (Node x ts) = f x (map go ts) |
|||
commasFromTree :: Tree a -> String |
commasFromTree :: Tree a -> String |