Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Haskell Problem

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]

Name: Anonymous 2011-06-03 0:08

>>4
but that doesn't take advantage of abstraction already in place. It took me literally 10 seconds to come up with merge = sort.concat, but there's no telling how long the other solutions took. It all depends on whether that tiny boost in optimization is worth the time it took to code it

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List