Thank you all for your great code examples!

The goal of the function 'd-map' is to return a collection of maps
that looks like this:

 ({:headline "this", :points 1, :comments 10}
  {:headline "is", :points 2, :comments 20}
  {:headline "me", :points 3, :comments 30})


Based on Per's example using 'for' I came up with the following
implementation:

(d-map [:headline ["this" "is" "me"] ]
            [:points [1 2 3] ]
            [:comments [10 20 30] ])

(defn d-map [& args]
  (let [kv-list (for [ [head items] args, item items] [head item])
         len      (count args)]
     (map #(into {} %)
                 (partition len (apply interleave (partition len kv-
list))))))


This is quite a few functions for turning 'kv-list':

([:headline "this"] [:headline "is"] [:headline "me"] [:points 1]
[:points 2] ...)

into:
({:headline "this", :points 1, :comments 10} {:headline "is", :points
2, ...} ...)


Therefore, I would like to ask again if there is a more elegant way to
get to this result.

Stefan

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