Last active
August 29, 2015 14:09
-
-
Save Denommus/0fb854f920a5c268a518 to your computer and use it in GitHub Desktop.
Quicksort in different languages
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
import Data.List | |
import Control.Monad | |
import Control.Arrow | |
qsort :: (a -> a -> Bool) -> [a] -> [a] | |
qsort _ [] = [] | |
qsort comp (x:xs) = smaller ++ [x] ++ bigger | |
where (smaller, bigger) = join (***) (qsort comp) $ comp x `partition` xs | |
main :: IO () | |
main = do | |
let foo = [2, 1, 2, 3] | |
print $ qsort (>) foo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment