Created
December 28, 2019 01:53
-
-
Save fetfrum/2f75ac575e1d868736e268e041051dc7 to your computer and use it in GitHub Desktop.
Qsort Haskell
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
| -- Quicksort algorithm by Tony Hoare | |
| -- https://en.wikipedia.org/wiki/Quicksort | |
| qsort :: Ord a => [a] -> [a] | |
| qsort [] = [] | |
| qsort (x:xs) = | |
| let up = qsort [a | a <- xs, a > x] | |
| down = qsort [a | a <- xs, a <= x] | |
| in down ++ [x] ++ up |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment