Your manual composition of concat and map is the same as the built-in function mapcat.
Anyway, all this is what (for ...) does for you under the covers. -Per On Thu, Oct 7, 2010 at 1:52 PM, Michael Gardner <gardne...@gmail.com> wrote: > On Oct 7, 2010, at 1:29 AM, Stefan Rohlfing wrote: > >> Following an Enlive tutorial I wanted to implement a function 'd-map' >> that takes an arbitrary number of [:key (list of values)] parameters >> like this: >> >> (d-map [:headline ["this" "is" "me"] ] >> [:points [1 2 3] ] >> [:comments [10 20 30] ]) >> >> >> and returns a collection of [:key value] vectors where each value is >> grouped with its respective key: >> >> [ [:headline "this"] [:headline "is"] [:headline "me"] >> [:points 1] [:points 2] [:points 3] >> [:comments 10] [:comments 20] [:comments 30] ] > > I'd do something like: > > (defn d-map [& kvs] > (apply concat > (map > (fn [[key vals]] > (map (partial vector key) vals)) > kvs))) > > -- > 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