[Haskell-cafe] Re: New slogan for haskell.org

Mirko Rahn rahn at ira.uka.de
Thu Nov 29 05:45:39 EST 2007

> The following code is the direct translation of your Haskell code

> void f(int x, intset s) {
>   printf("%d, ", x);
>   f (intset_elem(s, x/2) ? 3*x : x/2, intset_put(s, x));
> }

No, not that easy. The Haskell code works with arbitrary precision 
Integer, the C code with a fixed size int. On a 32 bit machine, try to 
calculate a_{1805133}, which equals to 19591041024. Or a_{8392780} = 
26665583616. Or a_{8500000} = 10804333. These values are calculated with 
the Haskell program in 370s and ~1GB memory usage.

Fair enough, on the same machine a C program (*two* pages long) was able 
to calculate a_{23448481} = 594261577728 and a_{25000000} = 192365946 in 
50s and ~1GB memory usage.

/BR, Mirko Rahn

More information about the Haskell-Cafe mailing list