Skip to content

Commit 5188e8d

Browse files
committed
c4 1
1 parent 7746646 commit 5188e8d

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/eval/c4_1.scm

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
(define (list-of-values-left-to-right exps env)
3+
(if (null? exps)
4+
'()
5+
(let ((first-value (seck-eval (first-operand exps) env)))
6+
(cons first-value
7+
(list-of-values-left-to-right (rest-operands exps) env)))))
8+
9+
;; right-to-left is just the same

src/eval/eval.scm

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616
((cond? exp) (seck-eval (cond->if exp) env))
1717
((application? exp)
1818
(seck-apply (seck-eval (operator exp) env)
19-
(list-of-values (operand exp) env)))))
20-
19+
(list-of-values (operand exp) env)))
20+
(else
21+
(error 'seck-eval "eval failed to recognize expression" exp))))
2122

2223
; @(tools)
2324
(define (tagged-list? exp tag)
@@ -321,6 +322,7 @@
321322
(define (operand exp) (cdr exp))
322323
(define (first-operand exps) (car exps))
323324
(define (rest-operands exps) (cdr exps))
325+
; fetch a list of values, eval them and return results as list
324326
(define (list-of-values exps env)
325327
(if (null? exps)
326328
'()

0 commit comments

Comments
 (0)