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

Neil Mitchell ndmitchell at gmail.com
Mon Feb 5 11:59:38 EST 2007


Hi Miranda,

> How to calculate the sum of list of lists in Haskell?

What do you mean by this? What is the value of a list?

If you mean sum the numbers such that [[1,2],[3,4]] = 1+2+3+4 then you
are able to ask two alternative questions - how do i convert a list of
lists to a list, and how do i sum a list.

Both can be answered by Hoogle:

http://haskell.org/hoogle/?q=%5BInt%5D%20-%3E%20Int

The list of lists to a list is a bit easier so I'll leave you to solve
that one :)

Thanks

Neil


More information about the Haskell-Cafe mailing list