(define (make-account balance secret-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 p m)
(if (eq? p secret-passwd)
(cond
((eq? m 'withdraw) withdraw)
((eq? m 'deposit) deposit)
(else (error "Unknown request -- MAKE-ACCOUNT"
m)))
"Incorrect Password"))
dispatch)
Friday, June 19, 2009
Ex-3.3
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment