From leavens@larch.cs.iastate.edu Wed Feb 16 22:24:39 2005 Date: Wed, 16 Feb 2005 22:24:39 -0600 (CST) From: Gary T. Leavens To: Neil Kaul Cc: Com S 342 TAs -- Brian Patterson , Daniel Patanroi Subject: Re: map question Hi Neil, On Wed, 16 Feb 2005, Neil Kaul wrote: > I'm having syntax trouble getting map to work with two parameters. > > I want to do something like this: > (map (fix-attributes nm (attributed->attributes elt)) nm elt) > > But of course it doesn't work like that. I'm pretty sure I'm supposed to use > lambda in some way, but I don't know how to construct a map/lambda 2 parameter > combination like that. Section 5.2.2 of the Following the Grammar handout (only on the web, this was added after I passed it out in class) says in the second paragraph: "In the calls to map in Figure 4, the procedure argument is double-size itself. This is equivalent to (but slightly faster than) passing the procedure (lambda (wl) (double-size wl). However, in other problems using a lambda (or a named helping procedure) may be needed, because the procedure argument to map must be a procedure that takes exactly one argument. For an example, consider writing a procedure add-n-to-size, such that (add-n-to-size n wl) returns a window layout that is exactly like wl, except that each window has n added to both its width and height. In such a problem it would be convenient to use (lambda (wl) (add-n-to-size n wl)), as the procedure argument to map." Does that help? Gary T. Leavens Department of Computer Science, Iowa State University 229 Atanasoff Hall, Ames, Iowa 50011-1041 USA http://www.cs.iastate.edu/~leavens phone: +1-515-294-1580 --------------------------------------