diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-07-30 13:28:35 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-07-30 13:28:35 +0200 |
commit | cdd64714ad68980aaaa53bca0864d239cc2825ab (patch) | |
tree | eeefeb0c5363c76677f2c693eebe3df56012d1a2 /module | |
parent | Make glob.scm use include#. (diff) | |
download | calp-cdd64714ad68980aaaa53bca0864d239cc2825ab.tar.gz calp-cdd64714ad68980aaaa53bca0864d239cc2825ab.tar.xz |
Add stream-paginate.
Diffstat (limited to '')
-rw-r--r-- | module/srfi/srfi-41/util.scm | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/module/srfi/srfi-41/util.scm b/module/srfi/srfi-41/util.scm index 2da2b479..472170d7 100644 --- a/module/srfi/srfi-41/util.scm +++ b/module/srfi/srfi-41/util.scm @@ -86,6 +86,22 @@ (stream-map cadr (stream-filter car strm)) (stream-map cadr (stream-remove car strm))))) +(define-public (stream-split idx stream) + (stream-cons (stream-take idx stream) + (stream-drop idx stream))) + +(define-stream (stream-paginate% stream page-size) + (stream-match (stream-split page-size stream) + ((page . rest) + (if (stream-null? page) + stream-null + (stream-cons + page + (stream-paginate rest page-size)))))) + +(define*-public (stream-paginate stream optional: (page-size 10)) + (stream-paginate% stream page-size)) + ;; Evaluates @var{body} in a context where most list fundamentals are ;; replaced by stream alternatives. ;; commented defifinitions are items which could be included, but for |