Saturday, January 31st, 2009

Quicksort in the Erlang Shell

It seems that one of the canonical examples of the power/simplicity/elegance etc. of functional languages/recursion tends to be an implementation of Quicksort. In Pragmatic Programming Erlang it appears on page 62. qsort([]) -> []; qsort([Pivot|T]) -> qsort([X || X []; ([Pivot|T]) -> QSort([X || X Q = fun([],F) -> []; ([Pivot|T],F) -> F([X || X […]