Created
March 7, 2015 00:21
-
-
Save jkwok91/10fc7279c6153ee15f96 to your computer and use it in GitHub Desktop.
took me like a thousand years to realize that the end is [x] and not []... i've learned this...how many times? fuck my life. if this is bad then i am sorry
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 xs [] = xs | |
merge [] xs = xs | |
merge (x:xs) (y:ys) | |
| x > y = y:(merge (x:xs) ys) | |
| otherwise = x:(merge xs (y:ys)) | |
mergesort [] = [] | |
mergesort [x] = [x] | |
mergesort xs = merge (mergesort (take n xs)) (mergesort (drop n xs)) | |
where n = (length xs) `div` 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment