(define (make-account balance password) (define (withdraw amount) (if (>= balance amount) (begin (set! balance (- balance amount)) balance) "Insufficient funds")) (define (deposit amount) (set! balance (+ balance amount)) balance) (define (dispatch credential m) (if (not (eq? credential password)) (error "Incorrect password")) (cond ((eq? m 'withdraw) withdraw) ((eq? m 'deposit) deposit) (else (error "Unknown request -- MAKE-ACCOUNT" m)))) dispatch) ; 1 ]=> (define acc (make-account 100 'secret-password)) ; ; ;Value: acc ; ; 1 ]=> ((acc 'secret-password 'withdraw) 40) ; ; ;Value: 60 ; ; 1 ]=> ((acc 'some-other-password 'deposit) 50) ; ; ;Incorrect password