aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--csc/loop-test.csc9
-rw-r--r--csc/loop.csc12
2 files changed, 15 insertions, 6 deletions
diff --git a/csc/loop-test.csc b/csc/loop-test.csc
index e7341c6..9a74ad4 100644
--- a/csc/loop-test.csc
+++ b/csc/loop-test.csc
@@ -274,6 +274,15 @@
if (>= x 5) return x end)))
+(test loop-if-collect-and
+ (assert-equal
+ '(1 2 3 4 5 6 7 8 9 10)
+ (loop for i from 1 to 10
+ if (odd? i)
+ collect i
+ and collect (+ 1 i))))
+
+
(test loop-collect-advanced
(assert-equal
'(fred bob ken sue alice joe kris sunshine june)
diff --git a/csc/loop.csc b/csc/loop.csc
index 10e634b..69f9201 100644
--- a/csc/loop.csc
+++ b/csc/loop.csc
@@ -274,7 +274,7 @@
(set-cdr! acc-last p)
(set! list-acc p))
(set! acc-last p)))
- finally (return list-acc) clause* ...))
+ clause* ... finally (return list-acc)))
((loop-aux "accumulation" (continuation ...) (compound ...) append x into l clause* ...)
(let ((l '())
(last #f))
@@ -294,7 +294,7 @@
(set-cdr! acc-last p)
(set! list-acc p))
(set! acc-last p)))
- finally (return list-acc) clause* ...))
+ clause* ... finally (return list-acc)))
((loop-aux "accumulation" (continuation ...) (compound ...) count x into n clause* ...)
(let ((n 0))
(loop-aux continuation ...
@@ -305,7 +305,7 @@
(loop-aux continuation ...
(compound ... (when x
(set! number-acc (+ 1 number-acc))))
- finally (return number-acc) clause* ...))
+ clause* ... finally (return number-acc)))
((loop-aux "accumulation" (continuation ...) (compound ...) sum x into n clause* ...)
(let ((n 0))
(loop-aux continuation ...
@@ -314,7 +314,7 @@
((loop-aux "accumulation" (continuation ...) (compound ...) sum x clause* ...)
(loop-aux continuation ...
(compound ... (set! number-acc (+ x number-acc)))
- finally (return number-acc) clause* ...))
+ clause* ... finally (return number-acc)))
((loop-aux "accumulation" (continuation ...) (compound ...) maximize x into n clause* ...)
(let ((n 0)
(set #f))
@@ -334,7 +334,7 @@
(begin
(set! acc-last #t)
(set! number-acc temp)))))
- finally (return number-acc) clause* ...))
+ clause* ... finally (return number-acc)))
((loop-aux "accumulation" (continuation ...) (compound ...) minimize x into n clause* ...)
(let ((n 0)
(set #f))
@@ -354,7 +354,7 @@
(begin
(set! acc-last #t)
(set! number-acc temp)))))
- finally (return number-acc) clause* ...))
+ clause* ... finally (return number-acc)))
((loop-aux "accumulation-main-continuation" ((body ...) fin) (compound ...) clause* ...)
(loop-aux "main-clause-collector" ((body ... compound ...) fin) clause* ...))
((loop-aux "conditional" continuation compound if condition clause* ...)