Haskell - sum a list of lists using foldr/foldl

Viewed 4935

I'm trying to write functions to sum a list of lists (type Integer). I have already done it using map:

summat :: [[Integer]] -> Integer
summat (x:xs) = sum . map sum $ (x:xs)

but can't figure out, how to get it work using foldr/foldl. I tried something like:

summat2 :: [[Integer]] -> Integer
summat2 xs = foldr suma 0 xs
        where suma x _ = ???

but of course it only produces many errors. Do you have any hint for me? Maybe something with concat?

1 Answers
Related