Skip to content

Instantly share code, notes, and snippets.

@amalloy
Created December 29, 2011 00:56
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 amalloy/1530833 to your computer and use it in GitHub Desktop.
Save amalloy/1530833 to your computer and use it in GitHub Desktop.
user> (def tree '{:val root
:children [{:val left},
{:val right
:children [{:val rightleft}]}]})
user> (defn paths [{:keys [val children]}]
(if (seq children)
(for [child children,
path (paths child)]
(cons val path))
[[val]]))
user> (paths tree)
((root left) (root right rightleft))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment