[plt-scheme] Lambda in a list

From: Dor Kleiman (dor at ntr.co.il)
Date: Tue Nov 11 08:10:09 EST 2003

> 	(define a-thing
		(list 
			"an-item" 
			12 
			(lambda (x y) (+ x y))
			(lambda (x y) (- x y))
		)
	)

> a-thing
("an-item" 12 #<procedure:8:24> #<procedure:9:24>)
> (list-ref a-thing 2)
#<procedure:8:24>
> ((list-ref a-thing 2) 1 2)
3
> ((list-ref a-thing 3) 5 1)
4

I see no problem with it...

-----Original Message-----
From: Patricio Daniel Patrickson [mailto:ppatrickson at home.se]
Sent: Tuesday, November 11, 2003 2:57 PM
To: plt-scheme at list.cs.brown.edu
Subject: [plt-scheme] Lambda in a list


  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.