<div class="gmail_quote">On Sat, Sep 4, 2010 at 23:55, bearophile <span dir="ltr">&lt;<a href="mailto:bearophileHUGS@lycos.com">bearophileHUGS@lycos.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br>
It computes the result (ghc-6.8.2) in 0.93s using only 8.7 MB of memory.<br></blockquote><div><br>OK, so that may the difference between GHCi and GHC proper. Less than 1s is impressive.<br>I see I have GHC 6.12.3 on my system. I may give this code a try one day. I tend to do most (if not all) of my Haskell &#39;dips&#39; with GHCi.<br>
<br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im">
<br>
&gt; For my own D version, that is quite near the Rosetta Code version, I get<br>
&gt; 3.7s, 100 Mo of RAM. (-O -release -inline)<br>
&gt; Using the RC code (your own, translated from Java, right?), I get the same.<br>
&gt; Same result, same time, same memory consumption. Yeah, my code is not wrong :-)<br>
<br>
</div>On my very slow PC using DMD the D version requires about 2.7s and about max 92 MB of memory.<br></blockquote><div><br>Maybe my PC is even slower :-)<br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

<br>
The second Python version (the one by Hettinger) takes about 4.95s and less than 4.5 MB of memory.<br>
(The third Python version, that uses the eager array and Psyco is faster.)<br>
<br>
Are you able to write a short D version similar to the second Python version? (I have created one, but it&#39;s not as short as the second Python version, and it takes something like 4 seconds or more).<br></blockquote><div>
<br>Funnily, this second Python version was the only one I knew. So no, I&#39;m not able to do the deferred output in D. That&#39;s were the trick is anyway, to have the solution recurse on a &#39;younger&#39; version of itself. Maybe with lazy int delegates ?<br>
 <br><br>Philippe<br></div></div>