Created
September 24, 2017 19:03
-
-
Save marchev/dd0558d1630a9aa5928cc6404901036f to your computer and use it in GitHub Desktop.
Quicksort in Haskell
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 in Haskell | |
quicksort :: (Ord a) => [a] -> [a] | |
quicksort [] = [] | |
quicksort [x] = [x] | |
quicksort (x:xs) = | |
let lessThanOrEqualToXSorted = quicksort [y | y <- xs, y <= x] | |
greaterThanXSorted = quicksort [z | z <- xs, z > x] | |
in lessThanOrEqualToXSorted ++ [x] ++ greaterThanXSorted |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment