:: Num a => [a] -> a
The
sum function computes the sum of a finite list of numbers.
>>> sum []
0
>>> sum [42]
42
>>> sum [1..10]
55
>>> sum [4.1, 2.0, 1.7]
7.8
>>> sum [1..]
* Hangs forever *
The
product function computes the product of a finite list of
numbers.
>>> product []
1
>>> product [42]
42
>>> product [1..10]
3628800
>>> product [4.1, 2.0, 1.7]
13.939999999999998
>>> product [1..]
* Hangs forever *
A strict version of
sum. Unlike
sum this function is
always strict in the
Num argument, whereas the standard version
is only strict if the optimiser kicks in.
sum' [1, 2, 3] == 6
A strict version of
product.
product' [1, 2, 4] == 8
Strict version of sum that doesn’t leak space
With argument order flipped
Lazy with argument order flipped.