Skip to content

Instantly share code, notes, and snippets.

@slomo
Created May 6, 2013 20:40
Show Gist options
  • Save slomo/5528019 to your computer and use it in GitHub Desktop.
Save slomo/5528019 to your computer and use it in GitHub Desktop.
> bft = unfoldr f
> where
> f [] = Nothing
> f xs = Just (tops, concat subtrees)
> where
> (tops, subtrees) = unzip $ g xs
> where
> g ((Node l a r):xs) = (a, [l,r]):(g xs)
> g (Empty:xs) = g xs
> g [] = []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment