[Haskell-cafe] how to calculate the sum of list of lists?

Maxime Henrion mux at FreeBSD.org
Mon Feb 5 12:00:43 EST 2007


Miranda Kajtazi wrote:
> Help,
> 
> How to calculate the sum of list of lists in Haskell?

Do you mean something of the form Num a => [[a]] -> a ?

If so, this should do it:

Prelude> let foo = sum . concat

Prelude> foo [[1,2,3],[4,5]]
15

Cheers,
Maxime


More information about the Haskell-Cafe mailing list