File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
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 36
36
((cond? exp) (seck-eval (cond->if exp) env))
37
37
((and? exp) (seck-eval (and->if exp) env))
38
38
((or? exp) (seck-eval (or->if exp) env))
39
+ ((let? exp) (seck-eval (let->combination exp) env))
39
40
((application? exp)
40
41
(seck-apply (seck-eval (operator exp) env)
41
42
(list-of-values (operand exp) env)))
375
376
(define (lambda-body exp )
376
377
(cddr exp))
377
378
379
+ ; @(let)
380
+ (define (let? exp )
381
+ (tagged-list? exp 'let ))
382
+
383
+ (define (let->combination exp )
384
+ (let ((var-bindings (cadr exp))
385
+ (body (cddr exp)))
386
+ (let ((vars (map car var-bindings))
387
+ (values (map cadr var-bindings)))
388
+ (cons (cons 'lambda
389
+ (cons vars body))
390
+ values))))
378
391
379
392
; @(application)
380
393
(define application? pair?)
437
450
1 ))
438
451
(assert (equal? (seck-eval ' (op2 2 2 ) new-env)
439
452
4 ))
453
+ (assert (equal? (seck-eval ' (let ((a 3 )
454
+ (b 4 ))
455
+ (cons a b))
456
+ new-env)
457
+ (cons 3 4 )))
440
458
))
You can’t perform that action at this time.
0 commit comments