[plt-scheme] How to apply a multi-argument function to each element of a list

From: Carl Eastlund (carl.eastlund at gmail.com)
Date: Tue Mar 2 20:03:31 EST 2010

On Tue, Mar 2, 2010 at 7:51 PM, Ryan Culpepper <ryanc at ccs.neu.edu> wrote:
> Carl Eastlund wrote:
>> Barry,
>> There are a few options.
>> You can have the students write:
>> (define (encrypt-message m)
>>  (encrypt 17 40 m))
>> Then you dodge this problem entirely.
> And if 17 and 40 are not constants but computed from other arguments, you
> can use 'local' to put the function definition in the scope of the other
> arguments.
> Ryan

I would definitely recommend this method (local plus a "specialized"
definition) if the students are writing this code.  If it is merely a
harness you are providing, then the other options come into play.  As
nice as curried functions and partial application are, they are not
that natural in the Scheme setting and can surprise students in some
odd ways.


Posted on the users mailing list.