Created
January 9, 2015 04:51
-
-
Save CampingScorpion/8bd115687a161d6b20f0 to your computer and use it in GitHub Desktop.
update-in-wildcard
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
(defn update-in-wildcard | |
[m [k & ks] f & args] | |
(if ks | |
(reduce (fn [m k] | |
(assoc m k (apply update-in-wildcard (get m k) ks f args))) | |
m | |
(if (= k :*) | |
(if (vector? m) | |
(range 0 (count m)) | |
(keys m)) | |
[k])) | |
(reduce (fn [m k] | |
(assoc m k (apply f (get m k) args))) | |
m | |
(if (= k :*) | |
(if (vector? m) | |
(range 0 (count m)) | |
(keys m)) | |
[k])))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment