3 ms·
Oh look, one of my pet hates. Displaying a sieve that claims to be the Sieve of Eratosthenes, and yet it does modulo tests, and hence isn't. Edit: It was by c
by ColinWright 12y ago
Oh look, one of my pet hates. Displaying a sieve that claims to be the Sieve of Eratosthenes, and yet it does modulo tests, and hence isn't.
Edit: It was by chance that it happened to be the example in the "A taste of Ela" box at the top. Reloading the page makes the example change to something else, so if you are wondering what I'm talking about, reload the page until the "taste" box explicitly calls something the Sieve of Eratosthenes. It isn't.
- JadeNB 12y agoI guess that the Sieve of Eratosthenes is the algorithm implemented in http://www.cs.hmc.edu/~oneill/papers/Sieve-JFP.pdf http://www.cs.hmc.edu/~oneill/papers/Sieve-JFP.pdf ?
- ColinWright 12y agoThat paper does correctly deal with the issue. The conclusions in section 4 give an excellent summary.
- michaelcampbell 12y agoFor those not wanting to click reload a slew of times (it took me about 3 minutes of clicking!)... //Sieve of Eratosthenes primes xs = sieve xs where sieve [] = [] sieve (p::xs) = & p :: sieve [& x \\ x <- xs | x % p > 0] //Outputs: [2,3,5,7] primes [2..10]