Does a function that does this:
  (vary coll :x fn-x, :y fn-y)
  ; Equivalent to (assoc coll :x (fn-x (:x coll)), :y (fn-y (:y
coll)))
exist in the core or contrib APIs?

I'm surprised that I can't find any. It's a very natural extension of
assoc. But if there really isn't any, is the code below the best/most-
idiomatic/most-efficient way to implement such a function?

(defn vary [coll & keys-and-fns]
  (let [fn-map (apply arrray-map keys-and-fns)
        keys-and-vals (mapcat #((val %) (get coll (key %))) fn-map)]
    (apply assoc-args coll keys-and-vals)))

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to