Hola,
I'm looking for a function that updates a map value by calling a
function on it.
(def foo {:a 1})
So instead of this:
(assoc foo :a (inc (:a foo))) ; => {:a 2}
Something like this:
(map-fn foo :a inc) ; => {:a 2}
Does that exist somewhere, or should I be doing this in a different
way? If not, shouldn't it be included?
(defn map-fn
[m key fn & args]
(assoc m key (apply fn (get m key) args)))
Cheers,
Jeff
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en