Created
March 24, 2013 02:13
-
-
Save joaomilho/5230162 to your computer and use it in GitHub Desktop.
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
merge [] ys = ys | |
merge xs [] = xs | |
merge (x:xs) (y:ys) = if x <= y | |
then x : merge xs (y:ys) | |
else y : merge (x:xs) ys | |
mergesort [] = [] | |
mergesort [x] = [x] | |
mergesort xs = let (as, bs) = splitAt (length xs `quot` 2) xs | |
in merge (mergesort as) (mergesort bs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment