-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path4-4.5.scm
29 lines (27 loc) · 995 Bytes
/
4-4.5.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
;; this procedure was modified
(define (expand-clauses clauses)
(if (null? clauses)
'false
(let ((first (car clauses))
(rest (cdr clauses)))
(if (cond-else-clause? first)
(if (null? rest)
(sequence->exp (cond-actions first))
(error "ELSE clause isn't last -- COND->IF"
clauses))
;; vvv THIS CODE WAS ADDED
(if (cond-arrow-clause? first)
(list (make-lambda
(list '*value*)
(make-if '*value*
(list (cond-arrow-clause first) '*value*)
(expand-clauses rest)))
(cond-predicate first))
;; ^^^ THIS CODE WAS ADDED
(make-if (cond-predicate first)
(sequence->exp (cond-actions first))
(expand-clauses rest)))))))
;; new procedures
(define (cond-arrow-proc exp) (caddr exp))
(define (cond-arrow-clause? clause)
(eq? (cond-actions clause) '=>))