[Haskell-cafe] Re: Code and Perf. Data for Prime Finders (was: Genuine Eratosthenes sieve)

Lennart Augustsson lennart at augustsson.net
Sun Feb 25 04:48:43 EST 2007


OK.

Another weird thing is that much of the Haskell code seems to work  
with Integer whereas the C code uses int.  That doesn't seem fair.

	-- Lennart

On Feb 25, 2007, at 02:40 , Melissa O'Neill wrote:

> Someone asked if I'd include a "classic C" version of the Sieve in  
> my comparisons.  Having done so, Lennart wrote (slightly rephrased):
>> How did you compare the C version with the Haskell versions? The  
>> Haskell programs produce the Nth prime, whereas the C code  
>> produces the last prime less than M.
>
> True.  But since I have to know what M is to find the Nth prime,  
> it's easy enough to ask the C code to produce the right prime.
>
>> To make the C code to what the Haskell code does you need to set  
>> some upper bound that is related to the prime number  
>> distribution.  I see no trace of this in your code.
>
> The Haskell versions that go up to a limit do this, so I could  
> easily have written code to do it -- it's not hard, but has no real  
> bearing on the time complexity of the code, so I didn't bother.
>
> You could argue that it's cheating to tell it so blatantly when to  
> stop, but I hate the C code I'd found enough that I didn't really  
> want to touch it any more than I had to.
>
>
> A much more legitimate complaint about the comparison with the C  
> code is actually on space usage.  It uses much more space than some  
> of the algorithms it's competing with.  More about that in an  
> upcoming message.
>
>     Melissa.
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe



More information about the Haskell-Cafe mailing list