bank account example (1)
one bank account with one operation, initial deposit always $100
- (define withdraw (define bal 100) (lambda (i) (set! bal (- bal i)) bal))
- (withdraw 10) ==> 90
- (withdraw 10) ==> 80
puzzle
- can i replace (set! bal (- bal i)) by a procedure call (reduce bal i)?
- construct environment diagram to see why not