Skip to content

Instantly share code, notes, and snippets.

@Frozenlock
Created June 14, 2017 08:16
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 Frozenlock/1c75e0d52d1a51c0e5381e2a0dd5a252 to your computer and use it in GitHub Desktop.
Save Frozenlock/1c75e0d52d1a51c0e5381e2a0dd5a252 to your computer and use it in GitHub Desktop.
(defn build-paths
"Given a tree (map), return all the paths leading to a value."
[m]
(->> (for [[k v] m]
(if (map? v)
(map #(cons k %) (build-paths v))
[[k]]))
(apply concat)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment