Created
March 16, 2010 16:48
-
-
Save arohner/334206 to your computer and use it in GitHub Desktop.
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-many | |
"like update-in, but can call f on multiple values. If keyseq contains :*, will recurse on every item in the 'current' value. Returns the updated structure" | |
[ds [k & ks] f & args] | |
(if (= k :*) | |
(if ks | |
(map-same (fn [x] (apply update-in-many x ks f args)) ds) | |
(map-same f ds)) | |
(if ks | |
(assoc ds k (apply update-in-many (get ds k) ks f args)) | |
(assoc ds k (apply f (get ds k) args))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment