From fcc4ad30957dc1663a07fe3ad37e937d7466e860 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Thu, 21 Nov 2019 23:24:09 +0100 Subject: take-while, drop-while --- tests/stdlib.lisp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests/stdlib.lisp') 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)) -- cgit v1.2.3-54-g00ecf