Last active
November 15, 2016 19:01
-
-
Save kaveet/681a5c991f3d7a6eb5bfc4d55897e427 to your computer and use it in GitHub Desktop.
Haskell Quicksort Implementation
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
module Quicksort where | |
quicksort :: (Ord a) => [a] -> [a] | |
quicksort [] = [] | |
quicksort (x:xs) = quicksort [y | y <- xs, y <= x] ++ [x] ++ quicksort [y | y <- xs, y > x] | |
quicksort' :: (Ord a) => [a] -> [a] | |
quicksort' [] = [] | |
quicksort' (x:xs) = (quicksort' small) ++ [x] ++ (quicksort' big) | |
where | |
small = filter (< x) xs | |
big = filter (>= x) xs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment