(define x 5) (set! x (+ x 1)) ; binds x to 6 x ; no previous binding for y (set! y 5) ; produces "unbound variable" message ((lambda (x) (set! x (+ x 1)) (set! x (+ x 1)) x) 5) ; returns 7 ; x should still be bound to the value it had x (define a 0) ((lambda (x) (set! a (+ x 1)) (set! x (+ a 1)) (* a x)) 3) ; rebinds a to 4, then returns 20 ; x's binding doesn't change a x (define a 0) ((lambda (a x) (set! a (+ x 1)) (set! x (+ a 1)) (* a x)) 3 5) ; returns 42 ; a should still be bound to 0 a (define x 0) ((lambda (x) (set! x ((lambda (x) (set! x (+ x 1)) (+ x 1)) (+ x 1)) ) (+ x 5)) x) ; returns 8 ; x should still be bound to 0 x (define a 0) (define b 10) (define f (lambda (x a) (set! x (+ b 1)) (set! b (* b 2)) (g (+ a x)) ) ) (define g (lambda (b) (set! a 30) (+ a b) ) ) (f 3 14) ; returns 55 after rebinding the global a to 30 and the global b to 20 a b x