Create a gist now

Instantly share code, notes, and snippets.

data NestedList a = Elem a | List [NestedList a]
flatten = reverse . rec []
where
rec acc (List []) = acc
rec acc (Elem x) = x : acc
rec acc (List (x:xs)) = rec (rec acc x) (List xs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment