Created
April 6, 2014 09:04
-
-
Save christopher-beckham/10003377 to your computer and use it in GitHub Desktop.
This file contains 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
quicksort :: [Int] -> [Int] | |
quicksort [] = [] | |
quicksort [x] = [x] | |
quicksort xs = | |
quicksort(less) ++ [pivot] ++ quicksort(greater) | |
where | |
m = length xs `div` 2 | |
pivot = xs!!m | |
less = [ xs!!i | i <- [0..(length xs)-1], xs!!i <= pivot && i /= m ] | |
greater = [ xs!!i | i <- [0..(length xs)-1], xs!!i > pivot && i /= m ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment