(define (make-account balance password)
(let ((count 0)
(error-limit 1))
(define (withdraw amount)
(if (>= balance amount)
(begin (set! balance (- balance amount))
balance)
"Insufficient funds"))
(define (deposit amount)
(set! balance (+ balance amount)))
(define (dispatch m)
(cond ((eq? m 'withdraw) withdraw)
((eq? m 'deposit) deposit)
(else (error "Unknow request -- MAKE-ACCOUNT"
m))))
(define (validate p op)
(if (eq? password p)
(begin (set! count 0)
(dispatch op))
(begin (set! count (+ count 1))
(check-safe))))
(define (check-safe)
(if (> count error-limit)
call-the-cops
(error "error password")))
(define (call-the-cops n) "CALL THE COPS")
validate))
(define acc (make-account 100 'psw))
((acc 'ss 'withdraw) 10)
((acc 'sd 'withdraw) 2)
((acc 'df 'withdraw) 34)
((acc 'dd 'withdraw) 33)
((acc 'dd 'withdraw) 32)