From e028543baa552aa091fe3485b03da48d25ab8179 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Mon, 10 Aug 2020 17:23:34 +0200 Subject: Really start breaking apart HTML. --- module/srfi/srfi-41/util.scm | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'module/srfi') diff --git a/module/srfi/srfi-41/util.scm b/module/srfi/srfi-41/util.scm index 51671985..eda379a7 100644 --- a/module/srfi/srfi-41/util.scm +++ b/module/srfi/srfi-41/util.scm @@ -77,6 +77,18 @@ (define-public (stream->values stream) (apply values (stream->list stream))) + +;; Natural numbers from 1 and up, each number repeated 7 times. +(define-public (repeating-naturals from repeats) + (stream-unfold + cdr ; map + (const #t) ; continue? + (lambda (x) ; gen next + (if (= (1- repeats) (car x)) + (cons 0 (1+ (cdr x))) + (cons (1+ (car x)) (cdr x)))) + (cons 0 from))) + ;; Returns two values. A stream of all the elements in stream ;; which satisfiy @var{pred}, and a stream of those elements ;; that don't. @var{pred} is called once per value in the -- cgit v1.2.3