Created
September 26, 2014 17:22
-
-
Save apotheon/887edb6c7120c70d4f9e to your computer and use it in GitHub Desktop.
Elixr Quicksort
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule Quicksort do | |
| def qsort([]) do | |
| [] | |
| end | |
| def qsort([pivot | tail]) do | |
| qsort( lc x inlist tail, x < pivot, do: x ) ++ [pivot] ++ qsort( lc x inlist tail,x >= pivot, do: x ) | |
| end | |
| end | |
| IO.puts inspect(Quicksort.qsort([10,9,1,3,5,6,4,2,8,7])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment