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

2012-08-19 Thread Ray Racine
Plans for TR support for generic interfaces down the road? (: add (All (K V [M <: (Gen:Dict K V)]) M K V -> M)) On Sun, Aug 19, 2012 at 6:11 PM, Asumu Takikawa wrote: > On 2012-08-19 11:20:01 -0700, Ian Tegebo wrote: > > Thanks for the clarification; I needed both `stream-cons` and > > `in-pr

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

2012-08-19 Thread Asumu Takikawa
On 2012-08-19 11:20:01 -0700, Ian Tegebo wrote: > 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? Sure. Vincent

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

2012-08-19 Thread Ian Tegebo
On Sat, Aug 18, 2012 at 10:51 PM, Asumu Takikawa 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> >> Unfortunately, 'in-generator' returns a sequence while 'take' needs a >> lis

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

2012-08-19 Thread Ian Tegebo
On Sat, Aug 18, 2012 at 10:39 PM, Richard Cleis wrote: > Are you looking for something like this? > > (define (tr2 k n) (build-list k (lambda (x) (random n Nice, I hadn't paid enough attention to `build-list` - I'll use it in place of my `call-n-times`. While I don't think this addresses the

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

2012-08-18 Thread Danny Yoo
On Sunday, August 19, 2012, Ian Tegebo wrote: > I want to, > > (take k (in-generator (infinite-generator (yield (random n) > > where k and n are positive integers, k > Unfortunately, 'in-generator' returns a sequence while 'take' needs a > list and calling 'sequence->list' results in an error.

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

2012-08-18 Thread Asumu Takikawa
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 > Unfortunately, 'in-generator' returns a sequence while 'take' needs a > list and calling 'sequence->list' results in an error. One way to g

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

2012-08-18 Thread Richard Cleis
Are you looking for something like this? (define (tr2 k n) (build-list k (lambda (x) (random n ;; the x arg is unused (it counts up) rac On Aug 18, 2012, at 10:59 PM, Ian Tegebo wrote: > (define (call-n-times f n) >(define (helper f n lst) > (if (< n 1) > lst >

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

2012-08-18 Thread Ian Tegebo
I want to, (take k (in-generator (infinite-generator (yield (random n) where k and n are positive integers, klist' results in an error. So, I thought maybe I needed 'take' from 'lazy'. But it also complains about the index being too large. That's when I encountered a possible (minor) bug w