Code Review
Compare your solutions
#| BEGIN (Write your solution here) |#
(define (make-account balance db-pwd)
(define (withdraw amount)
(if (>= balance amount)
(begin (set! balance (- balance amount)) balance)
"Insufficient funds"
)
)
(define (deposit amount)
(set! balance (+ balance amount)) balance
)
(define (incorrect-pwd arg)
"Incorrect password"
)
(define (dispatch pwd m)
(cond
((not (eq? pwd db-pwd)) incorrect-pwd)
((eq? m 'withdraw) withdraw)
((eq? m 'deposit) deposit)
(else (error "Unknown request: MAKE-ACCOUNT" m))
)
)
dispatch
)
#| END |#