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