Skip to content

Instantly share code, notes, and snippets.

@deque-blog
Created December 22, 2016 20:06
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save deque-blog/dd46126888dbdd86a95a75a1e176efa0 to your computer and use it in GitHub Desktop.
merge :: (Ord a) => [a] -> [a] -> [a]
merge xs [] = xs
merge [] ys = ys
merge l@(x:xs) r@(y:ys)
| y < x = y : merge l ys -- Keeps it stable
| otherwise = x : merge xs r
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment