From fed28363fb60266c030a0f6b30d5a9d697774ee0 Mon Sep 17 00:00:00 2001 From: Rose Hogenson Date: Tue, 28 Jun 2022 15:58:36 -0700 Subject: Improve CPS. Goodbye soup. Thanks to "Compiling with Continuations" by Appel. --- csc/list.csc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'csc/list.csc') 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))))) -- cgit v1.3.1