Created
December 29, 2011 00:56
-
-
Save amalloy/1530833 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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