Re: [racket-users] Idiomatic way to include numbers in a map?

2017-03-03 Thread David Storrs
That's very cool. Thank you, Matthew. On Fri, Mar 3, 2017 at 6:50 PM, Matthew Butterick wrote: > > On Mar 2, 2017, at 9:17 AM, David Storrs wrote: > > I could, it's just extremely more verbose and therefore obfuscates what's > actually going on as

Re: [racket-users] Idiomatic way to include numbers in a map?

2017-03-03 Thread Matthew Butterick
> On Mar 2, 2017, at 9:17 AM, David Storrs wrote: > > I could, it's just extremely more verbose and therefore obfuscates what's > actually going on as compared to the 'map' form. Why not turn it into a macro that preserves your preferred notation: #lang racket

Re: [racket-users] Idiomatic way to include numbers in a map?

2017-03-02 Thread Greg Hendershott
There is a "generic" `sequence-map`. But it's not variadic like `map` -- and like you want in your example. You could try writing a variadic `sequence-map`? As for `for/list`, you _could_ write: (for/list ([a as] [b bs] [n (in-naturals)]) (foo a b n)) It's faster if

Re: [racket-users] Idiomatic way to include numbers in a map?

2017-03-02 Thread David Storrs
On Thu, Mar 2, 2017 at 12:15 PM, David Storrs wrote: > > > > On Thu, Mar 2, 2017 at 11:22 AM, David Christiansen < > da...@davidchristiansen.dk> wrote: > >> > Not with map, which requires equal-length arguments. >> > >> > You could do the slightly less ugly: >> > >> >

Re: [racket-users] Idiomatic way to include numbers in a map?

2017-03-02 Thread David Storrs
On Thu, Mar 2, 2017 at 11:22 AM, David Christiansen < da...@davidchristiansen.dk> wrote: > > 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))) > > Why not do it

Re: [racket-users] Idiomatic way to include numbers in a map?

2017-03-02 Thread David Christiansen
> 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))) Why not do it this way? (struct foo (a b c)) (define lst-A '(a b)) (define lst-B '(d e)) (for/list ([a (in-list lst-A)]

Re: [racket-users] Idiomatic way to include numbers in a map?

2017-03-02 Thread Stephen Chang
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 wrote: > > > On Thu, Mar 2, 2017 at 10:09 AM, Stephen Chang

Re: [racket-users] Idiomatic way to include numbers in a map?

2017-03-02 Thread David Storrs
On Thu, Mar 2, 2017 at 10:09 AM, Stephen Chang 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

Re: [racket-users] Idiomatic way to include numbers in a map?

2017-03-02 Thread Stephen Chang
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)) On Thu, Mar 2, 2017 at 9:55 AM, David Storrs wrote: > I'd like to be able to

[racket-users] Idiomatic way to include numbers in a map?

2017-03-02 Thread David Storrs
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