Skip to content

Instantly share code, notes, and snippets.

@Denommus
Last active August 29, 2015 14:09
Show Gist options
  • Save Denommus/0fb854f920a5c268a518 to your computer and use it in GitHub Desktop.
Save Denommus/0fb854f920a5c268a518 to your computer and use it in GitHub Desktop.
Quicksort in different languages
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