Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Please, get rid off the primes example, as it is horrible inefficient (in the sense of, "Ok, let's find the first n primes by a simple well-known algorithm, like the Sieve of Eratosthenes") and a simple (non-pure) array-based approach will kick its ass.

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 :)



Even though it's a good example, I think extra care should be taken to avoid the stereotype that Haskell is elegant for math and academic stuff but not for the real word.


It's just as if you showed off insertion sort. Even if it looks good, it's not the best algorithm to show off.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: