Hi

      f1 :: [Int] -> [[Int]]
       f1 []     = []
      f1 (a:as) = [a] : f1 as

f1 is simply a map

      f3 la lb = let a = head la
                      b = head lb
                 in if sum a <= sum b then
                        a : f3 (tail la) lb
                     else
                        b : f3 la (tail lb)

Why not use pattern matching to split up la and lb, rather than head/tail?

I would have thought the whole function could be written as a nice
foldr merge, where merge :: [Int] -> [Int] -> [Int]. Thats only a
guess at the top of my head though, not worked out properly.

Is this homework? If so its useful to state when you post the question :)

Thanks

Neil
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to