Re: Functional random data streams
Marc Nieper-Wißkirchen 09 May 2020 08:31 UTC
> > Lazy sequences are straightforward, as SRFI 127 already has generator->lseq and lseq->generator. Stream->generator is also straightforward, but I do not see offhand how to write generator->stream.
>
> SRFI 41 already has PORT->STREAM.
So we should add
(define-stream (generator->stream g)
(let ((obj (g)))
(if (eof-object? obj)
stream-null
(stream-cons obj (generator->stream g)))))
either to SRFI 41 or SRFI 158 (or rather to backward compatible
replacements). The procedure `stream->generator` should also go
somewhere. It seems to make sense to put `generator->stream` along the
other SRFI 41 procedures and `stream->generator` along the other SRFI
158 constructors.