>>> import qualified Data.Vector as V >>> V.accumulate (+) (V.fromList [1000,2000,3000]) (V.fromList [(2,4),(1,6),(0,3),(1,10)]) [1003,2016,3004]
>>> import qualified Data.Vector.Strict as V >>> V.accumulate (+) (V.fromList [1000,2000,3000]) (V.fromList [(2,4),(1,6),(0,3),(1,10)]) [1003,2016,3004]
>>> import qualified Data.Vector.Unboxed as VU >>> VU.accumulate (+) (VU.fromList [1000,2000,3000 :: Int]) (VU.fromList [(2,4),(1,6),(0,3),(1,10)]) [1003,2016,3004]
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)
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)
accumulate_ (+) <5,9,2> <2,1,0,1> <4,6,3,7> = <5+3, 9+6+7, 2+4>
accumulate_ (+) <5,9,2> <2,1,0,1> <4,6,3,7> = <5+3, 9+6+7, 2+4>
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)