q3.7
(define (make-joint account ourpass genpass) (define (withdraw amo) ((account 'withdraw genpass) amo)) (define (deposit amount) ((account 'deposit genpass) amo)) (define (dispatch m p) (if (eq? ourpass p) (cond ((eq? m 'withdraw) withdraw) ((eq? m 'deposit) deposit) (else (error "can not dispatch!"))) (error "autho fail.") ) ) dispatch) (define (make-accountP balance passwd) (define (withdraw amount) (if (>= balance amount) (begin (set! balance (- balance amount)) balance ) "Insufficient funds" )) (define (deposit amount) (set! balance (+ balance amount)) balance) (define (dispatch m p) (if (eq? passwd p) (cond ((eq? m 'withdraw) withdraw) ((eq? m 'deposit) deposit) (else (error "Unknown request --MAKE-ACCOUNT"))) (error "Authorizagion Fail.") ) ) dispatch) (define W1 (make-accountP2 100 'pa)) ((W1 'withdraw 'pa) 20) (define WW1 (make-joint W1 'pas 'pa)) ((WW1 'withdraw 'pas) 20)
きっとOK。