-
Notifications
You must be signed in to change notification settings - Fork 0
/
3.3.scm
29 lines (27 loc) · 978 Bytes
/
3.3.scm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
(define (make-acc balance password)
(lambda (pass sele)
(cond ((not (eq? pass password)) "Wrong Password")
((eq? sele 'deposit)
(lambda (amount)
(set! balance (+ balance amount))
balance))
((eq? sele 'withdraw)
(lambda (amount)
(if (> balance amount)
(begin
(set! balance (- balance amount))
balance)
"Too few money" )))
(else "Bad selector"))))
(define (make-acc1 balance password)
(lambda (pass sele amount)
(cond ((not (eq? pass password)) "wrong pass")
((eq? sele 'deposit)
(begin (set! balance (+ balance amount))
balance))
((eq? sele 'withdraw)
(if (> balance amount)
(begin (set! balance (- balance amount))
balance)
"too few cash"))
(else "badoviy selector"))))