On 17 Dec 2009, at 15:44, Sean Devlin wrote:
> 1. I'd call it map-vals (as opposed to map-keys)
>
> 2. Slight change in the body
>
> (defn map-vals [f coll]
> (into {} (map (juxt key (comp f val)) coll))
>
> There is talk of getting something like this into contrib. Stay
> tuned :)
There's already clojure.contrib.generic.functor/fmap, which is a
multimethod whose implementation for maps does just that. Here's the
code:
(defmethod fmap clojure.lang.IPersistentMap
[f m]
(into (empty m) (for [[k v] m] [k (f v)])))
Konrad.
--
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