Hacker News new | past | comments | ask | show | jobs | submit login

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-...




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)




Consider applying for YC's W25 batch! Applications are open till Nov 12.

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

Search: