Skip to content

Instantly share code, notes, and snippets.

@klapaucius
Created September 19, 2012 06:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save klapaucius/3748017 to your computer and use it in GitHub Desktop.
Save klapaucius/3748017 to your computer and use it in GitHub Desktop.
> :{
let merge xs [] = xs
merge [] ys = ys
merge (x:xs) (y:ys) | x < y = x: merge xs (y:ys)
| otherwise = y: merge (x:xs) ys
:}
> :set -XNoMonomorphismRestriction
> let mergeAll = foldr1 merge
> take 20 $ mergeAll [[5..],[1..],[3..],[7..],[2..],[1..]]
[1,1,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,5,6,6]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment