you have to partition it first. user=> (partition 2 [1 2 3 4 5 6 7 8]) ((1 2) (3 4) (5 6) (7 8))
let's say we want to add the numbers. user=> (map #(apply + %) (partition 2 [1 2 3 4 5 6 7 8])) (3 7 11 15) On Wed, Jul 21, 2010 at 10:20 PM, Glen Rubin <rubing...@gmail.com> wrote: > Hi! I want to process a collection 2 elements at a time using map. > > My function accepts 2 parameters (a,b) and returns a result (c): > > (myfcn [a b]) > > => c > > so I want to iterate myfcn over a collection and create a new sequence > > for example let's say myfcn sums a and b, then i would like to do > something like this: > > (map myfcn '(1 2 3 4 5 6 7 8) > > => 3 7 11 15 > > accept i get the error that myfcn is being passed the wrong number of > arguments, since map is passing them in 1 at a time. How do I get map > to pass in 2 at a time? > > thx! > > -- > 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 -- Omnem crede diem tibi diluxisse supremum. -- 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