Skip to content

Instantly share code, notes, and snippets.

@AlexBaranosky
Created January 9, 2015 04:51
Show Gist options
  • Save AlexBaranosky/8bd115687a161d6b20f0 to your computer and use it in GitHub Desktop.
Save AlexBaranosky/8bd115687a161d6b20f0 to your computer and use it in GitHub Desktop.
update-in-wildcard
(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