Quiz 4 - Closures

CS 152 - Spring 2008

Name:

Student ID:

E-mail:

Consider the following Scheme procedure.

(define (foo n) 
   (lambda (i) (set! n (* n i)) n))

Show what gets printed when each of these Scheme expressions evaluates?

(define x (foo 2))


(x 3)


(x 7)


(define y (foo 3))


(y 3)


(y 7)


(x 5)


(y 5)