Flatten a list: Difference between revisions
→{{header|Haskell}}
Line 1,710:
= Leaf a
| Node [Tree a]
flatten :: Tree a -> [a]
flatten (Leaf x) = [x]
flatten (Node xs) =
main :: IO ()
main =
Line 1,728:
, Node []
]
--
Yet another choice, custom data structure, efficient lazy flattening:
|