time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

repl.txt (1170B)


      1 
      2 {{alias}}( collection, initial, reducer[, thisArg] )
      3     Applies a function against an accumulator and each element in a collection
      4     and returns the accumulated result.
      5 
      6     When invoked, the reduction function is provided four arguments:
      7 
      8     - `accumulator`: accumulated value
      9     - `value`: collection value
     10     - `index`: collection index
     11     - `collection`: the input collection
     12 
     13     If provided an empty collection, the function returns the initial value.
     14 
     15     Parameters
     16     ----------
     17     collection: Array|TypedArray|Object
     18         Input collection. If provided an object, the object must be array-like
     19         (excluding strings and functions).
     20 
     21     initial: any
     22         Accumulator value used in the first invocation of the reduction
     23         function.
     24 
     25     reducer: Function
     26         Function to invoke for each element in the input collection.
     27 
     28     thisArg: any (optional)
     29         Execution context.
     30 
     31     Returns
     32     -------
     33     out: any
     34         Accumulated result.
     35 
     36     Examples
     37     --------
     38     > function sum( acc, v ) { return acc + v; };
     39     > var arr = [ 1.0, 2.0, 3.0 ];
     40     > var out = {{alias}}( arr, 0, sum )
     41     6.0
     42 
     43     See Also
     44     --------
     45