Edit: mods, thanks for changing the misleading title.
Edit: mods, thanks for changing the misleading title.
1. Could make at least some sense to somebody that knows zero Haskell
2. Isn't too trivial
3. Isn't leaning too heavily on libraries
4. Is at least somewhat "real"/performant
Your example doesn't address any of the constraints of the medium.
If you can think of a better example for that part of the website, it would be welcomed on the mailing list.
I've been watching people try to figure out something that isn't too weak in any of those dimensions for months and now you're going to post an article with a title calling them liars because you want more attention for your blog? What would satisfy you? Renaming the sieve function? What do we need to do to prevent people like you from writing an article like this again?
Edit: There, I fixed it and it's merged https://github.com/haskell-infra/hl/pull/114
We're calling it a filter instead of a sieve.
I explained that Haskell had quickly become my favorite language over the past year. And I started partly because I saw these overly simplified algorithms and thought they were beautiful. Only after working with Haskell for awhile do you realize these algorithms are kinda 'lies'.
But, I realized nobody would care about that, and they would want me to get right into the algorithm. So I deleted the paragraph.
That's why I gave the post that title.
Prepare for the ire of pedantic set theorists, and the ensuing clickbait articles about it. /s
I thought it was a great read, and totally didn't take the "Haskell programmers are liars" literally ...
... until I saw #4 on your list and that this example was actively discussed on the mailing list and ultimately determined to satisfy it.
Haskell is really nice. Keep looking for a better example. :)
I'm just a barnacle writing a book so people stop saying Haskell is hard.
prime n = notElem 0 $ map (mod n) [2..n-1]
primes n = filter prime [2..n]
which at least doesn't pretend to be something it's not. It's also easier to optimize (take the root of `n` in `prime`).The quicksort you're thinking of isn't a real quicksort and would bring on the same criticism.
>Even if not, you can simplify it to
Nah. I just wanted to get rid of the word sieve, not create more surface area for bikeshedding.
If you're saying that because it's not in-place, I'll point you to:
http://en.wikipedia.org/wiki/Quicksort#Space_complexity
If you're saying that for another reason, why?
> Nah. I just wanted to get rid of the word sieve, not create more surface area for bikeshedding.
I was pointing out something that fits your four points, which is what you asked for.