by hss54 · 12y ago · 0 comments
Such a toy-example just contributes to the wrong belief that Haskell is just useful in academics or teaching. Some time ago I did implement the sieve in several languages and I also considered Haskell but set for an unpure approach (IOUArray) and it was extremely fast (getting close to C/C++ and outperforming Go, Java, etc.). Obviously such an example is not good to present Haskell's novel ideas but this toy example is worse then no example.
edit: Sorry, did not want to appear nit-picky, I like the language and the new design.
The primes example may be a bit awkward for people with no background in math but it's also an excellent example to demonstrate lazy evaluation in Haskell.
The interesting bit is that primes is an infinite list, containing all prime numbers. Don't try to print the whole list or count the sum unless you have a computer with infinite memory :)