aboutsummaryrefslogtreecommitdiffstats
path: root/csc/list.csc
diff options
context:
space:
mode:
authorRose Hogenson <rhogenson@posteo.net>2022-06-28 15:58:36 -0700
committerRose Hogenson <rhogenson@posteo.net>2022-06-28 15:58:36 -0700
commitfed28363fb60266c030a0f6b30d5a9d697774ee0 (patch)
tree50ed1ec9663371220559e4d4bfc7b1cd1bcb7117 /csc/list.csc
parent52da9c556a170ed8e5f811c3acd56088baf94c80 (diff)
downloadchromatopelma-fed28363fb60266c030a0f6b30d5a9d697774ee0.tar.zst
Improve CPS.
Goodbye soup. Thanks to "Compiling with Continuations" by Appel.
Diffstat (limited to 'csc/list.csc')
-rw-r--r--csc/list.csc10
1 files changed, 7 insertions, 3 deletions
diff --git a/csc/list.csc b/csc/list.csc
index cc64168..b1c2298 100644
--- a/csc/list.csc
+++ b/csc/list.csc
@@ -74,8 +74,12 @@
finally (return (values xs ys))))
- (define (all pred l)
- (loop for x in l
- unless (pred x)
+ (define (all pred . ls)
+ (loop for ls = ls then (map cdr ls)
+ while (loop for l in ls
+ if (null? l)
+ return #f
+ finally (return #t))
+ unless (apply pred (map car ls))
return #f
finally (return #t)))))