Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
data NestedList a = Elem a | List [NestedList a]
flatten = reverse . rec []
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