Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
14 lines (11 sloc) 304 Bytes
-- P07 Flatten a nested list structure.
data NestedList a = Value a | List [NestedList a]
-- Recursion
f1 :: NestedList a -> [a]
f1 (Value a) = [a]
f1 (List []) = []
f1 (List (x:xs)) = (f1 x) ++ f1(List xs)
-- Using concatMap
f2 :: NestedList a -> [a]
f2 (Value a) = [a]
f2 (List xs) = concatMap f2 xs