Code Review
Compare your solutions
#| BEGIN (Write your solution here) |#
(define (make-account balance correct-password)
(let ((attempts 0))
(define (withdraw amount)
(if (>= balance amount)
(begin (set! balance (- balance amount))
balance)
"Insufficient funds"))
(define (deposit amount)
(set! balance (+ balance amount))
balance)
(define (call-the-cops)
(error "Cops called"))
(define (dispatch password m)
(if (not (eq? password correct-password))
(begin (set! attempts (+ attempts 1))
(if (> attempts 7)
(call-the-cops)
(error "Wrong password")))
(begin (set! attempts 0)
(cond ((eq? m 'withdraw) withdraw)
((eq? m 'deposit) deposit)
(else (error "Unknown request -- MAKE-ACCOUNT"
m))))))
dispatch))
#| END |#