Skip to content

Instantly share code, notes, and snippets.

@trevorc
Created December 1, 2011 19:22
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 trevorc/1419150 to your computer and use it in GitHub Desktop.
Save trevorc/1419150 to your computer and use it in GitHub Desktop.
bfs :: Tree a -> [a]
bfs t =
concatMap (map rootLabel) $
takeWhile (not . null) $
iterate (concatMap subForest) [t]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment