Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #lang racket
- ;; cw. 1
- (define (make-account balance password)
- (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? password p)
- (cond ((eq? m 'withdraw) withdraw)
- ((eq? m 'deposit) deposit)
- (else (error "Unknown request -- MAKE-ACCOUNT"
- m)))
- (error "Wrong password" p)))
- dispatch)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement