[plt-scheme] cannot get mapping over procedures (procedure applications) to work

From: Will M Farr (farr at MIT.EDU)
Date: Mon Apr 27 11:23:51 EDT 2009


On Apr 27, 2009, at 11:16 AM, keydana at gmx.de wrote:

> this seems like a horribly stupid thing to ask, but I have problems  
> to map over procedures (in order to apply them). When I try
> (map (lambda (fun) (fun 1 2)) '(* +))
> I get
> "procedure application: expected procedure, given: *; arguments  
> were: 1 2"

The expression

(map (lambda (fun) (fun 1 2)) '(* +))

maps the procedure (lambda (fun) (fun 1 2)) over a list which contains  
two symbols: '* and '+.  Trying to apply the symbol '* to the  
arguments 1 2 gives the error.  You probably wanted to write

(map (lambda (fun) (fun 1 2)) (list * +))

where the list will contain the values to which '* and '+ are bound in  
the current environment---that is, the list will be a list of two  
procedures which multiply and add, respectively.

Hope this helps!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 203 bytes
Desc: This is a digitally signed message part
URL: <http://lists.racket-lang.org/users/archive/attachments/20090427/5b4ae1ae/attachment.sig>

Posted on the users mailing list.