On Sat, Sep 4, 2010 at 23:55, bearophile <bearophileh...@lycos.com> wrote:
> > It computes the result (ghc-6.8.2) in 0.93s using only 8.7 MB of memory. > OK, so that may the difference between GHCi and GHC proper. Less than 1s is impressive. 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 'dips' with GHCi. > > > For my own D version, that is quite near the Rosetta Code version, I get > > 3.7s, 100 Mo of RAM. (-O -release -inline) > > Using the RC code (your own, translated from Java, right?), I get the > same. > > Same result, same time, same memory consumption. Yeah, my code is not > wrong :-) > > On my very slow PC using DMD the D version requires about 2.7s and about > max 92 MB of memory. > Maybe my PC is even slower :-) > > The second Python version (the one by Hettinger) takes about 4.95s and less > than 4.5 MB of memory. > (The third Python version, that uses the eager array and Psyco is faster.) > > Are you able to write a short D version similar to the second Python > version? (I have created one, but it's not as short as the second Python > version, and it takes something like 4 seconds or more). > Funnily, this second Python version was the only one I knew. So no, I'm not able to do the deferred output in D. That's were the trick is anyway, to have the solution recurse on a 'younger' version of itself. Maybe with lazy int delegates ? Philippe