From 634502e7246f8850ad6c649b79ae9f072f45baf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Mon, 11 Sep 2023 17:54:35 +0200 Subject: Introduce stream-split-by. This procedure isn't currently used, but as noted is really useful for grouping a character stream into a word stream, which is a later commit will use for it for justifying posibly infinite streams of text. --- doc/ref/guile/srfi-41.texi | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'doc/ref') diff --git a/doc/ref/guile/srfi-41.texi b/doc/ref/guile/srfi-41.texi index 310751ec..d8020ecc 100644 --- a/doc/ref/guile/srfi-41.texi +++ b/doc/ref/guile/srfi-41.texi @@ -73,6 +73,26 @@ times. stream cons, but eval arguments beforehand. @end defun +@defun stream-split-by pred strm +Chunks the content of @var{strm} into lists, breaking on @var{pred}. +If the end of the stream is reached, the remaining objects +are put into a final chunk. + +Can for example be used to split a stream of characters into a stream +of words. + +@lisp +(stream-split-by (lambda (c) (char=? c #\space)) + (-> "This is a short test" + string->list list->stream)) +⇒ # +@end lisp +@end defun + @defun stream-timeslice-limit stream timeslice Wrap a stream in time limits. Each element has at most @var{timeslice} seconds to produce a value, otherwise the stream ends. Useful for finding the -- cgit v1.2.3