Skip to content

Instantly share code, notes, and snippets.

@the-swerve
Created April 2, 2014 03:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save the-swerve/9927619 to your computer and use it in GitHub Desktop.
Save the-swerve/9927619 to your computer and use it in GitHub Desktop.
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