[plt-scheme] Lambda in a list

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Tue Nov 11 10:15:58 EST 2003

You had the parens at the wrong place:

Welcome to DrScheme, version 205.5-cvs5nov2003.
Language: Intermediate Student with lambda.
 > (define a-thing
     (list
      "an-item"
      12
      (lambda (x y) (+ x y))
      (lambda (x y) (- x y))))
 > ((list-ref a-thing 2) 5 10)
15
 >

On Tuesday, November 11, 2003, at 07:56 AM, Patricio Daniel Patrickson 
wrote:

>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
> Hi!
>
>    I am stuck on a problem.
>
>    I am trying to create a list where two of the elements are lambda
>    expressions? Some thing like "'("an-item" 12 a-lambda-expr
>    another-lambda-expr)".
>
>    Here is how I am defining it.
>
> 	(define a-thing
> 		(list
> 			"an-item"
> 			12
> 			(lambda (x y) (+ x y))
> 			(lambda (x y) (- x y))
> 		)
> 	)
>
>    What I want to do with this construct is to retrieve the third item
>    from a-thing, and the execute it with two arguments. This is
>    obvously not working, could anybody please tell me why?
>
> Best Regards!
> /Daniel Patrickson
>
> _____________________________________
> Patricio Daniel Patrickson
> http://ppatrickson.servehttp.com
> tel:0739848646



Posted on the users mailing list.