On Tuesday, 12 March 2019 19:21:12 UTC+1, Ben Greenman wrote:
>
> You can also use sequences: 
>
> #lang racket/base 
> (require racket/sequence) 
>
> (sequence-ref (in-producer (let ([i 0]) (lambda () (begin0 i (set! i 
> (+ i 1)))))) 
>               20000000) 
> (sequence-ref (in-naturals) 
>               20000000) 
>

Thank you.

The actual sequence was building a list for each element.
I had a recursive algorithm to produce this. But the total list was 
definitely too big. So I was hoping that by turning it into a stream I 
could avoid keeping every element in memory.
In the end I used a generator and modified the algorithm to track state...

KR.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to