Created
October 10, 2022 07:06
-
-
Save rotaliator/26d320222d0c6eb24e2743099601006e to your computer and use it in GitHub Desktop.
Clojure deep get
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
(defn deep-get | |
[m k] | |
(let [values_ (transient [])] | |
(walk/prewalk (fn [e] (if (and (map? e) (get e k)) | |
(do (conj! values_ (get e k)) e) | |
e)) m) | |
(persistent! values_))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment