4 ms·
That's not really the Sieve of Eratosthenes. The list data structure is not well suited for the algorithm. See [1] for a proper discussion. As someone who wants
by sa1 10y ago
That's not really the Sieve of Eratosthenes. The list data structure is not well suited for the algorithm. See [1] for a proper discussion. As someone who wants to write Haskell(and loves it) for code with mathematically well defined guarantees, the propagation of such examples, where the guarantees or behavior is not clear to the author, is not helpful.
[1]: https://www.cs.hmc.edu/~oneill/papers/Sieve-JFP.pdf https://www.cs.hmc.edu/~oneill/papers/Sieve-JFP.pdf
- harpocrates 10y agoCannot agree more. I think the usual example of quicksort also falls under this category. [1]: http://stackoverflow.com/questions/7717691/why-is-the-minimalist-example-haskell-quicksort-not-a-true-quicksort http://stackoverflow.com/questions/7717691/why-is-the-minima...
- pera 10y agoIt's the same example displayed in haskell.org though.
- seagreen 10y agoTotally fair point. haskell.org has a very . . . casual approach to presenting the language. It's been such an issue some people made an alternate homepage at haskell-lang.org.
- kmill 10y agoOr if Python's your thing: http://www.kylem.net/stuff/sieve_eratosthenes.html http://www.kylem.net/stuff/sieve_eratosthenes.html