Skip to content

Instantly share code, notes, and snippets.

@jkwok91
Created March 7, 2015 00:21
Show Gist options
  • Save jkwok91/10fc7279c6153ee15f96 to your computer and use it in GitHub Desktop.
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
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