aboutsummaryrefslogtreecommitdiff
path: root/module
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-07-16 23:35:50 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2022-07-16 23:35:50 +0200
commit16e68df7cacf367bffa06ec2ca23ee151b2dfa6c (patch)
treed3c41eba09a01c36e04e1b50601fb45f8c5f7e51 /module
parentFix nested #if (diff)
downloadcalp-16e68df7cacf367bffa06ec2ca23ee151b2dfa6c.tar.gz
calp-16e68df7cacf367bffa06ec2ca23ee151b2dfa6c.tar.xz
Add break/all.
Diffstat (limited to 'module')
-rw-r--r--module/hnh/util.scm10
1 files changed, 10 insertions, 0 deletions
diff --git a/module/hnh/util.scm b/module/hnh/util.scm
index 9a45704b..096e38c5 100644
--- a/module/hnh/util.scm
+++ b/module/hnh/util.scm
@@ -36,6 +36,7 @@
split-by
split-by-one-of
+ break/all
span-upto
cross-product
@@ -367,6 +368,15 @@
(lambda (first rest) (cons (cdr first) rest))))))
+(define (break/all predicate lst)
+ (let loop ((lst lst))
+ (if (null? lst)
+ '(())
+ (let ((fst rest (break predicate lst)))
+ (if (null? rest)
+ (list fst)
+ (cons fst (loop (cdr rest))))))))
+
;; Simar to span from srfi-1, but never takes more than
;; @var{count} items. Can however still take less.
;; @example