Skip to content

Instantly share code, notes, and snippets.

@apotheon
Created September 26, 2014 17:23
Show Gist options
  • Select an option

  • Save apotheon/87808f70613a0fbc76e4 to your computer and use it in GitHub Desktop.

Select an option

Save apotheon/87808f70613a0fbc76e4 to your computer and use it in GitHub Desktop.
Erlang Quicksort
quicksort( [] ) -> [].
quicksort( [FirstElement | RestOfList] ) ->
SmallerThan = fun(X) -> X < FirstElement end,
{ Smaller, LargerOrEq } = lists:partition(SmallerThan, RestOfList),
quicksort(Smaller) ++ [FirstElement] ++ quicksort(Larger).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment