Chapter 3, Modularity, Objects, and State

Exercise 3.8


The idea is to save the new value and return the new value. And if called first time then use 0 as old-value.

1
(define f ((lambda(old) (lambda(x) (let ((temp old)) (set! old x) temp))) 0)) 

Output:

1
0

Thus DrRacket evaluates from left to right.