sum -package:streaming

The sum function computes the sum of the numbers of a structure.

Examples

Basic usage:
>>> sum []
0
>>> sum [42]
42
>>> sum [1..10]
55
>>> sum [4.1, 2.0, 1.7]
7.8
>>> sum [1..]
* Hangs forever *
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 *
O(n) Compute the sum of the elements.

Examples

>>> import qualified Data.Vector as V

>>> V.sum $ V.fromList [300,20,1]
321

>>> V.sum (V.empty :: V.Vector Int)
0
O(n) Compute the sum of the elements.

Examples

>>> import qualified Data.Vector.Strict as V

>>> V.sum $ V.fromList [300,20,1]
321

>>> V.sum (V.empty :: V.Vector Int)
0
O(n) Compute the sum of the elements.

Examples

>>> import qualified Data.Vector.Primitive as VP

>>> VP.sum $ VP.fromList [300,20,1 :: Int]
321

>>> VP.sum (VP.empty :: VP.Vector Int)
0
O(n) Compute the sum of the elements.

Examples

>>> import qualified Data.Vector.Storable as VS

>>> VS.sum $ VS.fromList [300,20,1 :: Int]
321

>>> VS.sum (VS.empty :: VS.Vector Int)
0
O(n) Compute the sum of the elements.

Examples

>>> import qualified Data.Vector.Unboxed as VU

>>> VU.sum $ VU.fromList [300,20,1 :: Int]
321

>>> VU.sum (VU.empty :: VU.Vector Int)
0
Get the sum of all values in the stream. Subject to fusion
Compute the sum of the elements of a Producer
Computes the sum of all elements
Stricter version of sum.
>>> sum [1..10]
55
The sum of elements in the original Sample. This is the sample's first simple power.
The sum function computes the sum of the numbers of a structure.
O(n) Compute the sum of the elements

Examples

>>> import qualified Data.Vector as V

>>> V.sum $ V.fromList [300,20,1 :: Int]
321

>>> V.sum (V.empty :: V.Vector Int)
0
O(n) Compute the sum of the elements

Examples

>>> import qualified Data.Vector as V

>>> V.sum $ V.fromList [300,20,1 :: Int]
321

>>> V.sum (V.empty :: V.Vector Int)
0
O(n) Compute the sum of the elements

Examples

>>> import qualified Data.Vector.Storable as VS

>>> VS.sum $ VS.fromList [300,20,1 :: Int]
321

>>> VS.sum (VS.empty :: VS.Vector Int)
0
O(n) Compute the sum of the elements

Examples

>>> import qualified Data.Vector.Unboxed as VU

>>> VU.sum $ VU.fromList [300,20,1 :: Int]
321

>>> VU.sum (VU.empty :: VU.Vector Int)
0
Synonym for osum
sum does not need a zero for initialization
Sum of values
Sum of values
The sum of the list