Name: Anonymous 2011-06-02 20:24
Write a function merge :: (Ord a) => [[a]] -> [a] that
takes a finite list of sorted finite lists and merges them into a single sorted
list. A “sorted list” means a list sorted in increasing order (using <); you
may assume that the sorted lists are finite. For example
merge ([[]]::[[Int]]) = [] :: [Int]
merge [[1, 2, 3]] = [1, 2, 3]
merge [[1, 3, 5, 7], [2, 4, 6]] = [1,
2, 3, 4, 5, 6, 7]
merge [[1,3,5,7], [2,4,6],
[3,5,9,10,11,12]] =
[1,2,3,3,4,5,5,6,7,9,10,11,12]
take 8 (merge [[1, 3, 5, 7],
[1,2,3,4,5,6,7,8]]) = [1, 1, 2, 3, 3,
4, 5, 5]
takes a finite list of sorted finite lists and merges them into a single sorted
list. A “sorted list” means a list sorted in increasing order (using <); you
may assume that the sorted lists are finite. For example
merge ([[]]::[[Int]]) = [] :: [Int]
merge [[1, 2, 3]] = [1, 2, 3]
merge [[1, 3, 5, 7], [2, 4, 6]] = [1,
2, 3, 4, 5, 6, 7]
merge [[1,3,5,7], [2,4,6],
[3,5,9,10,11,12]] =
[1,2,3,3,4,5,5,6,7,9,10,11,12]
take 8 (merge [[1, 3, 5, 7],
[1,2,3,4,5,6,7,8]]) = [1, 1, 2, 3, 3,
4, 5, 5]