[racket] taking from a generator, and a possible bug

From: Ian Tegebo (ian.tegebo at gmail.com)
Date: Sun Aug 19 14:20:01 EDT 2012

On Sat, Aug 18, 2012 at 10:51 PM, Asumu Takikawa <asumu at ccs.neu.edu> wrote:
> On 2012-08-18 21:59:28 -0700, Ian Tegebo wrote:
>> (take k (in-generator (infinite-generator (yield (random n)))))
>> where k and n are positive integers, k<n.
>> Unfortunately, 'in-generator' returns a sequence while 'take' needs a
>> list and calling 'sequence->list' results in an error.
> One way to get around this without using the `lazy` language is to use
> stream functions. Sequences can be converted to streams, which are
> general things that can be `first` and `rest`ed.
Thanks for the clarification; I needed both `stream-cons` and
`in-producer` examples.  Also, your tone regarding the stream API
suggests there might be ongoing work and/or other interesting details.
 If so, could you elaborate?

Ian Tegebo

Posted on the users mailing list.