Hi, today I needed to use the map function on multiple collections which didn't had all the same length. In this case, it returns a sequence of the size of smallest one. But the problem I was facing was required to map until the end of the longest, padding the smaller ones with a default value. I came up with this:
(defn mappad [f val & colls] (let [longest (apply max (map count colls)) colls (map #(if (< (count %) longest) (concat % (repeat val)) %) colls)] (apply (partial map f) colls))) user> (mappad #(+ %1 %2 %3) 0 [1] [2 3] [4 5 6]) (7 8 6) Is there a better way? - budu -- 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