Comprehension with two variables - explanation needed

Rustom Mody rustompmody at gmail.com
Mon Nov 24 07:47:07 CET 2014


On Monday, November 24, 2014 10:13:04 AM UTC+5:30, Steven D'Aprano wrote:
> On Sun, 23 Nov 2014 08:45:39 -0800, Rustom Mody wrote:
> > First a one-line solution in haskell
> > 
> > sieve (p:xs)   =    p:sieve [x | x <- xs, x `mod` p /= 0]
> 
> Don't use that! That is a horribly inefficient way to generate primes.
> 
> Mathematically, it is a version of Euler's Sieve. It is sometimes wrongly 
> described as "Sieve of Eratosthenes", but that is wrong. Due to it's 
> horrible performance, Melissa O'Neill calls this the "Sleight on 
> Eratosthenes":
> 
> http://www.cs.hmc.edu/~oneill/papers/Sieve-JFP.pdf

Thanks for that link -- I'll need to look at it carefully



More information about the Python-list mailing list