Title: RE: Odd Performance
You may also like to compare this definition.
> import List
>
> primes = unfoldr sieve [2..]
> sieve (x:xs) = Just (x,filter (x `notDivisor`) xs)
> x `notDivisor` y = y `mod` x /= 0
Slower, but (IMO) cuter.
Cheers,
-Original Message-
Tom Pledger writes:
> Probably. Try replacing this
>(\z -> z <= (intsqrt x))
> with this
>(\z -> z^2 <= x)
Yes! This is significantly nicer. Taking 4000 primes, this is about twice
as fast as the original (loose) algorithm, and it appears that it gets
better as n grows. (Call this versio