time-to-botec

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

repl.txt (1309B)


      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, iterating from right to left.
      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 ) {
     39     ...     console.log( '%s: %d', acc, v );
     40     ...     return acc + v;
     41     ... };
     42     > var arr = [ 1.0, 2.0, 3.0 ];
     43     > var out = {{alias}}( arr, 0, sum );
     44     2: 3.0
     45     1: 2.0
     46     0: 1.0
     47     > out
     48     6.0
     49 
     50     See Also
     51     --------
     52