Hello,
in clojure.core we have assoc and assoc-in, dissoc and dissoc-in (in
the incubator), but there is only update-in, without update.
Implementation might look like this:
(defn update [m & kfs]
(let [coll (partition 2 kfs)]
(reduce (fn [m [k f]] (update-in m [k] f))
m coll)))
This can be used as follows:
(update {:a 1 :b 2 :c 3} :a inc :c dec)
=> {:a 2, :b 2, :c 2}
Any thoughts?
--
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