On Sun, Oct 11, 2009 at 3:17 PM, Daniel Werner <
daniel.d.wer...@googlemail.com> wrote:

> 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.


Agreed. That's why I may create a kind of "mind map" of that library (and
throw in clojure.core) that can find functions by, well, function. So all
the stuff for manipulating maps can be found, or all the stuff for file I/O,
etc.

--~--~---------~--~----~------------~-------~--~----~
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