|I can't believe this hasn't come up here before, but it's true. Inspired by http://blog.thezerobit.com/2012/09/01/beautiful-quicksort-in-common-lisp.html:|
That compares pretty well with haskell:
(iflet (p . xs) l
(join (qsort:keep [< _ p] xs) list.p (qsort:keep [>= _ p] xs))))
I actually find keep with the anonymous arg more readable than the list comprehensions.
qsort (p:xs) = qsort [x | x<-xs, x<p] ++ [p] ++ qsort [x | x<-xs, x>=p]
Is there some way to get haskell's implicit handling of empty lists?
I spent some time trying to build qsort using anarki's partition. No luck.