(define (new-account balance) (define (withdraw amount) (if (>= balance amount) (begin (set! balance (- balance amount)) balance) (error "Insufficient funds") ) ) (define (deposit amount) (set! balance (+ balance amount)) balance) (define (respond-to-msg msg) (cond ((eq? msg 'withdraw) withdraw) ((eq? msg 'deposit) deposit) (else (error "Unknown operation")) ) ) respond-to-msg)