News for hackers. Stuff that matters.
Re:I learned Haskell in just 15 years by trealira on Monday June 17, 2024 @11:16AM (#40706453)
I know you're being sarcastic, but even in this linked-list quicksort, it could be made more efficient. By defining lesser and greater separately, you're traversing the list twice. You could compute them at the same time by changing those last two lines to this:

  where
    (lesser, greater) = partition (< p) xs
I just learned about the existence of this function today, and wonder why I had never seen it used before.

https://hackage.haskell.org/package/base-4.20.0.1/docs/Data-...

Re:I learned Haskell in just 15 years by chuckadams on Monday June 17, 2024 @11:46AM (#40706849)
Heh, I've used some version of partition in my TS/JS code ever since underscore.js. But "Haskell Quicksort" is basically a code meme now, and I didn't think to optimize it (though I think the original was a one-liner using list comprehensions)