Skip to content

Instantly share code, notes, and snippets.

@Frozenlock
Created June 14, 2017 08:16
Show Gist options
  • 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