Hi Stuart, I believe you might looking for zipmap:
------------------------- clojure.core/zipmap ([keys vals]) Returns a map with the keys mapped to the corresponding vals. This is used as follows: user=> (zipmap [:a :b :c] [[1 2] [3 4] [5 6]]) {:c [5 6], :b [3 4], :a [1 2]} There are a lot of handy functions like this in core but you really need to know they exist before you can use them. Discovering new ones is always exciting! Sam --- http://sam.aaron.name On 17 Jan 2011, at 16:56, Stuart Popejoy wrote: > Greetings, > > Apologies if this seems like a pointless question but a) searches were > fruitless and b) hopefully this is interesting to consider ... > > I'm wanting to create a map from two seqs (:keys and values), and it > seems surprisingly tricky. > > I would rather not use hash-map, but if I did the following would > suffice: > > => (apply hash-map (apply concat (map vector [:a :b :c] [[1 2] [2 3] > [3 4]]))) > {:a [1 2], :c [3 4], :b [2 3]} > > The quick answer would be a function equivalent to {} in the place of > hash-map above, but I can't find such a thing. > > My two answers are: > a) compose assoc functions: > => ((apply comp (map #(fn [m] (assoc m % %2)) [:a :b :c] [[1 2] [2 3] > [3 4]])) nil) > {:a [1 2], :b [2 3], :c [3 4]} > > b) recursion: > => (loop [[k & ks] [:a :b :c] [v & vs] [[1 2] [2 3] [3 4]] m {}] (if > (not k) m (recur ks vs (assoc m k v)))) > {:c [3 4], :b [2 3], :a [1 2]} > > Both seem wizzy/overly complex. I should probably just use hash- > map ... but am I missing some elegant way to perform this with vanilla > map? > > Thanks, > Stuart > > -- > 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 -- 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