Hacker News new | ask | show | jobs
by anindyabd 3948 days ago
I wouldn't call recursion boring. Quicksort in Haskell is probably my favorite two lines of code:

  quicksort [] = []
  quicksort (x:rest) = quicksort [y | y <- rest, y <= x] ++ [x] ++ quicksort [y | y <- rest, y > x]
2 comments

It's been discussed before, but that's not really quicksort though (since it's not in-place)[0]

0: http://stackoverflow.com/q/7717691/1235548

Do we know that for sure? I mean - could a sufficiently smart compiler actually create machine code which _did_ do it in-place?
This variant (with the <= comparison) takes c N^2 on lists of length N that a repeated constant ( http://www.win-vector.com/blog/2008/04/sorting-in-anger/ ).