Did you try this (apply hash-map (partition 2 (split (slurp "data") #",")))
On Sat, Dec 4, 2010 at 11:12 AM, Remco van 't Veer <rwvtv...@gmail.com>wrote: > I expected this to work: > > (into {} (partition 2 (split (slurp "data") #","))) > > But unfortunately, `into' doesn't seem to allow pushing lists of pairs > into a map. But vectors are allowed: > > (into {} (map vec (partition 2 (split (slurp "data") #",")))) > > Can somebody explain why vectors are allowed and lists not? > > > On 2010/12/03 15:40, Laurent PETIT wrote: > > > Hi, > > > > 2010/12/3 Anclj <anb...@gmail.com> > > > > Hi, > > > > I have a string of data and I would like to get a map {:key > > value, :key value, …} > > > > How could I do that? > > > > I've got: > > > > user> (split (slurp "data") #",") > > ["0" "2" "1" "5" "2" "8" "3" "15" "4" "9"] > > > > And I would like: > > {:0 2, :1 5, :2 8, :3 15, :4 9} > > > > Any idea? > > > > (let [s (split (slurp "data") #",")] > > (zipmap (take-nth 2 s) (take-nth 2 (rest s)))) > > > > HTH, > > > > -- > > Laurent > > > > -- > > 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<clojure%2bunsubscr...@googlegroups.com> > > For more options, visit this group at > > http://groups.google.com/group/clojure?hl=en > > -- > 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<clojure%2bunsubscr...@googlegroups.com> > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en -- *Satajanus Nig. Ltd * -- 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