accumulate

O(m+n) For each pair (i,b) from the vector of pairs, replace the vector element a at position i by f a b.

Examples

>>> import qualified Data.Vector as V

>>> V.accumulate (+) (V.fromList [1000.0,2000.0,3000.0]) (V.fromList [(2,4),(1,6),(0,3),(1,10)])
[1003.0,2016.0,3004.0]
O(m+n) For each pair (i,b) from the vector of pairs, replace the vector element a at position i by f a b.

Examples

>>> import qualified Data.Vector as V

>>> V.accumulate (+) (V.fromList [1000.0,2000.0,3000.0]) (V.fromList [(2,4),(1,6),(0,3),(1,10)])
[1003.0,2016.0,3004.0]
O(m+n) For each pair (i,b) from the vector of pairs, replace the vector element a at position i by f a b.

Examples

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

>>> VU.accumulate (+) (VU.fromList [1000.0,2000.0,3000.0]) (VU.fromList [(2,4),(1,6),(0,3),(1,10)])
[1003.0,2016.0,3004.0]
O(m+n) For each pair (i,b) from the vector of pairs, replace the vector element a at position i by f a b.
accumulate (+) <5,9,2> <(2,4),(1,6),(0,3),(1,7)> = <5+3, 9+6+7, 2+4>
O(m+n) For each pair (i,b) from the vector of pairs, replace the vector element a at position i by f a b.
accumulate (+) <5,9,2> <(2,4),(1,6),(0,3),(1,7)> = <5+3, 9+6+7, 2+4>
O(m+n) For each pair (i,b) from the vector of pairs, replace the vector element a at position i by f a b.
accumulate (+) <5,9,2> <(2,4),(1,6),(0,3),(1,7)> = <5+3, 9+6+7, 2+4>
O(m+n) For each pair (i,b) from the vector of pairs, replace the vector element a at position i by f a b.
accumulate (+) <5,9,2> <(2,4),(1,6),(0,3),(1,7)> = <5+3, 9+6+7, 2+4>
Combinator for the accumulate attribute.
O(m+n) For each pair (i,b) from the vector of pairs, replace the non-empty vector element a at position i by f a b.
>>> accumulate (+) (unsafeFromList [1..3]) (V.fromList [(2,10)])
[1,2,13]
>>> accumulate (+) (unsafeFromList [1..3]) V.empty
[1,2,3]
Accumulates input values using a folding function and yields that accumulated value each sample. This is analogous to a stepwise foldl.
>>> testVarOver (accumulate (++) []) $ words "hey there man"
"hey"
"heythere"
"heythereman"
>>> print $ foldl (++) [] $ words "hey there man"
"heythereman"
O(m+min(n1,n2)) For each index i from the index vector and the corresponding value b from the the value vector, replace the element of the initial vector at position i by f a b.
accumulate_ (+) <5,9,2> <2,1,0,1> <4,6,3,7> = <5+3, 9+6+7, 2+4>
The function accumulate provides the same functionality and is usually more convenient.
accumulate_ f as is bs = accumulate f as (zip is bs)
O(m+min(n1,n2)) For each index i from the index vector and the corresponding value b from the the value vector, replace the element of the initial vector at position i by f a b.
accumulate_ (+) <5,9,2> <2,1,0,1> <4,6,3,7> = <5+3, 9+6+7, 2+4>
This function is useful for instances of Vector that cannot store pairs. Otherwise, accumulate is probably more convenient:
accumulate_ f as is bs = accumulate f as (zip is bs)
O(m+min(n1,n2)) For each index i from the index vector and the corresponding value b from the the value vector, replace the element of the initial vector at position i by f a b.
accumulate_ (+) <5,9,2> <2,1,0,1> <4,6,3,7> = <5+3, 9+6+7, 2+4>
O(m+min(n1,n2)) For each index i from the index vector and the corresponding value b from the the value vector, replace the element of the initial vector at position i by f a b.
accumulate_ (+) <5,9,2> <2,1,0,1> <4,6,3,7> = <5+3, 9+6+7, 2+4>
The function accumulate provides the same functionality and is usually more convenient.
accumulate_ f as is bs = accumulate f as (zip is bs)
O(m+n) For each index i from the index vector and the corresponding value b from the the value vector, replace the element of the initial vector at position i by f a b.
accumulate_ (+) <5,9,2> <2,1,0,1> <4,6,3,7> = <5+3, 9+6+7, 2+4>
This function is useful for instances of Vector that cannot store pairs. Otherwise, accumulate is probably more convenient:
accumulate_ f as is bs = accumulate f as (zip is bs)
O(m+n) For each index i from the index vector and the corresponding value b from the the value vector, replace the element of the initial vector at position i by f a b.
accumulate_ (+) <5,9,2> <2,1,0,1> <4,6,3,7> = <5+3, 9+6+7, 2+4>
This function is useful for instances of Vector that cannot store pairs. Otherwise, accumulate is probably more convenient:
accumulate_ f as is bs = accumulate f as (zip is bs)
O(m+n) For each index i from the index vector and the corresponding value b from the the value vector, replace the element of the initial vector at position i by f a b.
accumulate_ (+) <5,9,2> <2,1,0,1> <4,6,3,7> = <5+3, 9+6+7, 2+4>
This function is useful for instances of Vector that cannot store pairs. Otherwise, accumulate is probably more convenient:
accumulate_ f as is bs = accumulate f as (zip is bs)
O(m+n) For each index i from the index vector and the corresponding value b from the the value vector, replace the element of the initial vector at position i by f a b.
accumulate_ (+) <5,9,2> <2,1,0,1> <4,6,3,7> = <5+3, 9+6+7, 2+4>
This function is useful for instances of Vector that cannot store pairs. Otherwise, accumulate is probably more convenient:
accumulate_ f as is bs = accumulate f as (zip is bs)
O(m+n) For each index i from the index vector and the corresponding value b from the the value vector, replace the element of the initial vector at position i by f a b.
accumulate_ (+) <5,9,2> <2,1,0,1> <4,6,3,7> = <5+3, 9+6+7, 2+4>
This function is useful for instances of Vector that cannot store pairs. Otherwise, accumulate is probably more convenient:
accumulate_ f as is bs = accumulate f as (zip is bs)