SICP to the rescue<div><a href="http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-24.html#%_sec_3.5.2">http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-24.html#%_sec_3.5.2</a><br><br></div><div>Probably inspiring in the context of this thread.</div>
<div>Bye</div><div>Enrico</div><div><br><div class="gmail_quote">On Wed, Feb 10, 2010 at 8:16 AM, Levente Uzonyi <span dir="ltr"><<a href="mailto:leves@elte.hu">leves@elte.hu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div></div><div class="h5">On Tue, 9 Feb 2010, Andreas Raab wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Colin Putney wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Also, Stephen Pair posted an implementation here in December: <a href="http://n4.nabble.com/ANN-CoroutineReadStream-tt963004.html#a963004" target="_blank">http://n4.nabble.com/ANN-CoroutineReadStream-tt963004.html#a963004</a><br>
</blockquote>
<br>
Brilliant! That's the ticket! Once I got down the right path it's even simpler than that. I put a version of Generator into the inbox for people to play with and give feedback. With 5 methods total you get to do fun stuff like:<br>
<br>
| gen max |<br>
max := 10000000.<br>
gen := Generator on:[:yield| Integer primesUpTo: max do: yield].<br>
'Computing primes' displayProgressAt: Sensor cursorPoint<br>
from: 1 to: max during:[:bar| | prime |<br>
[prime := gen next] whileNotNil:[bar value: prime].<br>
].<br>
<br>
I think we should add support for Generators. They are so incredibly useful where you have complex operations that you don't want to spend the upfront effort on to compute everything (like primes) before you can do some work with the results.<br>
</blockquote>
<br></div></div>
I wonder how can you use generators to generate primes efficiently _and_ on the fly.<br>
<br>
<br>
Levente<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Cheers,<br>
- Andreas<br>
<br>
<br>
</blockquote>
<br>
</blockquote></div><br><br clear="all"><br>-- <br>Enrico Spinielli<br>"Do Androids dream of electric sheep?"— Philip K. Dick<br>"Hear and forget; see and remember;do and understand."—Mitchel Resnick<br>
</div>