Of what use is 'lambda'???

Steven D. Majewski sdm7g at virginia.edu
Thu Sep 21 20:00:48 EDT 2000


On Thu, 21 Sep 2000, Kragen Sitaker wrote:

> 
> Unfortunately, although you can use the same syntax, it doesn't always
> work the same.  In SCM, this code works at the top level, but breaks
> inside a function:
> 
> (define (adder x) (lambda (y) (+ x y)))
> (define adder5 (adder 5))
> (define adder6 (adder 6))
> (adder5 (adder6 x))
> 
> It says:
> 
> unbound variable:  adder
> ; in expression: (... adder 5)
> ; in scope:
> ;   (adder adder5 adder6 . #@define)
> ;   (x)
> ;Evaluation took 0 mSec (0 in gc) 49 cells work, 5 env, 213 bytes other
> 


When I copy those lines into scm, I get:

ERROR: unbound variable:  x
; in expression: (... x)
; in top level environment.

which is just what I expect as "x" hasn't been defined.
If I do "(adder5 (adder6 1))" , I get "12" , as expected. 



---|  Steven D. Majewski   (804-982-0831)  <sdm7g at Virginia.EDU>  |---
---|  Department of Molecular Physiology and Biological Physics  |---
---|  University of Virginia             Health Sciences Center  |---
---|  P.O. Box 10011            Charlottesville, VA  22906-0011  |---
		"All operating systems want to be unix, 
		 All programming languages want to be lisp." 




More information about the Python-list mailing list