Skip to content

Instantly share code, notes, and snippets.

@arohner
Created March 16, 2010 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arohner/334206 to your computer and use it in GitHub Desktop.
Save arohner/334206 to your computer and use it in GitHub Desktop.
(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