repl.txt (816B)
1 2 {{alias}}() 3 Returns an accumulator function which incrementally computes a sum. 4 5 If provided a value, the accumulator function returns an updated sum. If not 6 provided a value, the accumulator function returns the current sum. 7 8 If provided `NaN` or a value which, when used in computations, results in 9 `NaN`, the accumulated value is `NaN` for all future invocations. 10 11 For long running accumulations or accumulations of large numbers, care 12 should be taken to prevent overflow. 13 14 Returns 15 ------- 16 acc: Function 17 Accumulator function. 18 19 Examples 20 -------- 21 > var accumulator = {{alias}}(); 22 > var s = accumulator() 23 null 24 > s = accumulator( 2.0 ) 25 2.0 26 > s = accumulator( -5.0 ) 27 -3.0 28 > s = accumulator() 29 -3.0 30 31 See Also 32 -------- 33