Not with map, which requires equal-length arguments.

You could do the slightly less ugly:

(map
    foo
    lst-A
    lst-B
    (range (length lst-A)))


On Thu, Mar 2, 2017 at 11:14 AM, David Storrs <david.sto...@gmail.com> wrote:
>
>
> On Thu, Mar 2, 2017 at 10:09 AM, Stephen Chang <stch...@ccs.neu.edu> wrote:
>>
>> The in-X forms are sequences, and must be used with the sequence API, ie
>> for/X.
>>
>> map only works with lists, so you could use build-list or range:
>> (map
>>     foo
>>     lst-A
>>     lst-B
>>     (range 2))
>>
> Is there a way to do it if I don't know how many items will be in the list?
> What I want is to say "just keep sticking numbers in until one of the lists
> runs out."  I could say (range 100000000) but that's ugly.
>
>
>>
>> On Thu, Mar 2, 2017 at 9:55 AM, David Storrs <david.sto...@gmail.com>
>> wrote:
>> > I'd like to be able to do something like this:
>> >
>> > (struct foo (a b c))
>> > (define lst-A '(a b))
>> > (define lst-B '(d e))
>> > (map
>> >     foo
>> >     lst-A
>> >     lst-B
>> >     (in-naturals))
>> >
>> > I'd expected this to produce:  (foo 'a 'd 0) (foo 'b 'e 1), but instead
>> > it
>> > throws an exception "expected list, given stream".  I could do it with a
>> > for/list but that's much more verbose.  What would be the idiomatic way
>> > of
>> > doing this?
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "Racket Users" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> > an
>> > email to racket-users+unsubscr...@googlegroups.com.
>> > For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to