(partition 2 coll) will give you the sequence two at a time.
To map your function, you'd do (map #(apply myfcn %) (partition 2 '(1
2 3 4 5 6 7 8)))

On Jul 21, 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

Reply via email to