<p dir="ltr">Ever? Or for the purpose discussed earlier?<br>
</p>
<div class="gmail_quote">On Sep 9, 2013 7:17 AM, "Matthias Felleisen" <<a href="mailto:matthias@ccs.neu.edu">matthias@ccs.neu.edu</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
I wonder whether you really want lazy streams. -- Matthias<br>
<br>
<br>
<br>
On Sep 9, 2013, at 10:19 AM, Lawrence Woodman wrote:<br>
<br>
> On 09/09/13 07:19, Stephen Chang wrote:<br>
>> Konrad's exactly right. Your filtered-nums blows up because you named<br>
>> the stream and then traversed the entire thing. In general, if you<br>
>> hang onto the head of the stream while traversing then the GC can't<br>
>> collect anything because since you have a pointer to the head, every<br>
>> element of the stream is still reachable.<br>
>><br>
>> Compare to a common traversal pattern like:<br>
>><br>
>> (let loop ([s <some stream>]) ... (loop (stream-rest s)))<br>
>><br>
>> where the head is dropped on each loop iteration.<br>
>><br>
>> Other comments:<br>
>> - (stream-length (gen-filtered-nums)) is fine because there's no<br>
>> pointer to the head, so the GC collects as you traverse.<br>
>><br>
>> - in-range is fine because it's constant space and not a<br>
>> cons-cell-based stream. It's more like a generator.<br>
>><br>
>> - the for/sum is actually collecting while traversing, just more<br>
>> slowly. I'm not exactly sure why, I may look into it. On my machine,<br>
>> it got up to 500mb or so but it finished.<br>
><br>
> Thanks, and to Konrad too. You're mention of in-range being more<br>
> like a generator, actually makes me wonder whether a generator would<br>
> be a better choice for processing large data sets, from databases and<br>
> csv files, sequentially. What do you think?<br>
><br>
><br>
> Lorry<br>
><br>
> --<br>
> vLife Systems Ltd<br>
> Registered Office: The Meridian, 4 Copthall House, Station Square, Coventry, CV1 2FL<br>
> Registered in England and Wales No. 06477649<br>
> <a href="http://vlifesystems.com" target="_blank">http://vlifesystems.com</a><br>
><br>
> ____________________<br>
> Racket Users list:<br>
> <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
<br>
<br>
____________________<br>
Racket Users list:<br>
<a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
</blockquote></div>