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

This is one that blew my mind back in the day, compare these two quicksort implementations: https://rosettacode.org/wiki/Sorting_algorithms/Quicksort#C https://rosettacode.org/wiki/Sorting_algorithms/Quicksort#Ha...


The C code implement quicksort, the Haskell code does not. It has different (worse) space characteristics. Proper quicksort in Haskell is not a two-liner.


Is it a parlour trick in lisp or erlang?


It's a parlor trick, but a cool one is my point.


But you can make that parlor trick work ok in C too if you even the playing field by implementing a partition() helper separately.

The Haskell version reveals more of a deficiency in the C standard library than the language.


A sort is a sort or it isn't a sort? Don't get it. Is the claim that the first quick sort impl. in haskell on rosetta is NOT a quick sort?


Quicksort is a specific algorithm involving two array pointers and swapping values. The haskell implementation in question is not it. It’s not a “claim”, it is what it is.


A parlor trick that doesn't implement what it claims to, even if cool, doesn't make a point very well...




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

Search: