Last active
August 11, 2022 10:32
-
-
Save MrEbbinghaus/98ff71810a139dee9ee96966008bd6fa to your computer and use it in GitHub Desktop.
Takes a (nested) map and returns all paths in that map
This file contains hidden or 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
| (fn paths [m] | |
| (reduce-kv | |
| (fn [acc k v] | |
| (into acc | |
| (map vec) | |
| (if (and (associative? v) (not (empty? v))) | |
| (map | |
| #(cons k %) | |
| (paths v)) | |
| [[k]]))) | |
| #{} | |
| m)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment