File tree Expand file tree Collapse file tree 2 files changed +21
-8
lines changed Expand file tree Collapse file tree 2 files changed +21
-8
lines changed Original file line number Diff line number Diff line change
1
+ ; in eval.scm
Original file line number Diff line number Diff line change 60
60
(let ((found (car ret))
61
61
(value (cadr ret)))
62
62
(cond (found value)
63
- ((null ? (base-env))
63
+ ((empty-env ? (base-env))
64
64
(error 'lookup " variable not defined" var))
65
65
(else
66
66
(((base-env) 'lookup ) var))))))
104
104
((env 'insert ) var value))
105
105
106
106
(define the-empty-env '())
107
+ (define (empty-env? env )
108
+ (null? env))
107
109
108
110
; @(expression)
109
111
130
132
(else
131
133
(make-begin seq))))
132
134
135
+ (define (sequence->exp-2 predicate actions )
136
+ (if (eq? (car actions) '=> )
137
+ ; transforms to '(cadr (= a 3)) if predicate is (= a 3)
138
+ ; Note predicate will evaluated twice in the conditions!
139
+ (list (cadr actions)
140
+ predicate)
141
+ (sequence->exp actions)))
142
+
133
143
(define (make-begin seq )
134
144
(cons 'begin seq))
135
145
315
325
'false
316
326
(let ((first (cond-firstmatch matches))
317
327
(rest (cond-restmatches matches)))
318
- (if (cond-elsematch? first)
319
- (if (null? rest)
320
- (make-if 'true (sequence->exp (cond-match-actions first)))
321
- (error 'cond " else is not last match" ))
322
- (make-if (cond-match-predicate first)
323
- (sequence->exp (cond-match-actions first))
324
- (expand rest))))))
328
+ (cond ((cond-elsematch? first) ; else
329
+ (if (null? rest)
330
+ (make-if 'true (sequence->exp (cond-match-actions first)))
331
+ (error 'cond " else is not last match" )))
332
+ (else ; the other conditions
333
+ (make-if (cond-match-predicate first)
334
+ (sequence->exp-2 (cond-match-predicate first)
335
+ (cond-match-actions first))
336
+ (expand rest)))))))
325
337
(expand (cdr exp)))
326
338
327
339
; @(and/or)
You can’t perform that action at this time.
0 commit comments