summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Smeding <tom.smeding@gmail.com>2019-11-21 23:24:09 +0100
committerTom Smeding <tom.smeding@gmail.com>2019-11-21 23:24:09 +0100
commitfcc4ad30957dc1663a07fe3ad37e937d7466e860 (patch)
tree17768446eaea018fa531c92c965c6454d9fa54bd
parent2afa7c1315f4a1b85a1ac6c45f788ed71a5900f0 (diff)
take-while, drop-while
-rw-r--r--tests/stdlib.lisp16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/stdlib.lisp b/tests/stdlib.lisp
index fd72dd8..e23364c 100644
--- a/tests/stdlib.lisp
+++ b/tests/stdlib.lisp
@@ -14,6 +14,22 @@
(do (f start) (for (+ start 1) end f))
'()))
+(define take-while (f l)
+ (cond
+ (null? l)
+ l
+ (f (car l))
+ (cons (car l) (take-while f (cdr l)))
+ '()))
+
+(define drop-while (f l)
+ (cond
+ (null? l)
+ l
+ (f (car l))
+ (drop-while f (cdr l))
+ l))
+
(define stdin (sys-stdin))
(define stdout (sys-stdout))
(define stderr (sys-stderr))