99-haskell-problems/Problems 01-10/problem_07.hs

7 lines
151 B
Haskell
Raw Normal View History

2024-05-24 17:06:42 -05:00
data NestedList a = Elem a | List [NestedList a]
flatten :: NestedList a -> [a]
flatten x = case x of
Elem e -> [e]
List l -> concatMap flatten l