On Mon, 04 May 2009 16:31:21 +0200 Christophe Grand <christo...@cgrand.net> wrote:
> > Nathan Hawkins a écrit : > > Ok, my example seems to have misled. You're missing the point a > > little bit: > > > > 1. I was trying to avoid the (reduce conj {} ...), by having the map > > function do it. Why even build a list that's only going to get > > thrown away when I want a hash-map at the end? > > > > 2. The functions used to split the strings were not important, only > > an example. It could just as easily be a function to extract fields > > from a java object. > > > > > > To some extent, I guess I'm thinking in terms of Common Lisp, where > > I'd build an a-list with mapcar and cons. > > > > With f a function that return a [key value] pair (or a (key value) > pair but not a {key value} pair): > (reduce #(apply assoc %1 (f %2)) {} coll) > > if you want to have f return a map you can > (reduce #(merge %1 (f %2)) {} coll) > This is exactly what I was trying to, but I hadn't thought of using reduce. Thank you. Nathan --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---