On Oct 11, 6:02 am, samppi <
rbysam...@gmail.com> wrote:
> Oops, you're right; I was thinking about something else. And I have
> another mistake in my function too—I meant:
>
> (defn transform-map [f a-map]
> (into {} (map #(vector (key %) (f (val %))) a-map)))
>
> It's unfortunate that it's not in any standard library yet. I've used
> this function in every single Clojure program that I've written. Ah,
> well.
Konrad Hinsen's generic functor multimethod seems to do exactly what
you want:
user=> (use 'clojure.contrib.generic.functor)
nil
user=> (fmap inc {:a 4, :b 3})
{:a 5, :b 4}
Actually it is not limited to maps:
user=> (fmap inc [4 3])
[5 4]
It's just too easy to miss beautiful and useful gems like this in the
depths of clojure.contrib.