On Wed, Oct 15, 2008 at 8:21 AM, Jim Menard <[EMAIL PROTECTED]> wrote:
>
> On Wed, Oct 15, 2008 at 7:46 AM, Timothy Pratley
> <[EMAIL PROTECTED]> wrote:
>>
>> Can I get some help with (map f coll)...
>>
>> What I want to do is map a java function that takes 2 arguments over a
>> list
>> where the first argument is the index into the list itself
>> and the second argument is taken from the list
>>
>> The problem being map uses a function of 1 argument.
>> Does that mean I need to create my own map, or is there a better way?
>
> map can take more than one argument. If it has N arguments, it calls f
> with N arguments, each taken from the Nth value of each collection. So
> you should be able to pass in an infinite sequence like this UNTESTED
> code:
>
>  (map f coll (range (count coll)))

Rather than (range (count coll)), I would use (iterate inc 0), which
incurs no overhead for counting the argument.

Best,
Graham

--~--~---------~--~----~------------~-------~--~----~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to