Function applied against an accumulator.
Function applied against an accumulator.
Callback invoked for each array element.
Callback invoked for each array element.
Function applied against an accumulator.
Callback invoked for each array element.
Callback invoked for each array element.
Function applied against an accumulator.
Function applied against an accumulator.
Function applied against an accumulator.
Callback invoked for each array element.
Function applied against an accumulator.
Callback invoked for each array element.
Function applied against an accumulator.
Performs a map-reduce operation for each element in an array while iterating from right to left and returns the accumulated result.
The mapping function is provided four arguments:
The reducing function is provided four arguments:
If provided an empty array, the function returns the initial value.
input array
initial value
mapping function
reducing function
reducing function execution context
accumulated result
var naryFunction = require( `@stdlib/utils/nary-function` );
var abs = require( `@stdlib/math/base/special/abs` );
var add = require( `@stdlib/math/base/ops/add` );
var array = require( `@stdlib/ndarray/array` );
var opts = {
'dtype': 'generic'
};
var arr = array( [ [ -1, -2, -3 ], [ -4, -5, -6 ] ], opts );
var out = mapReduceRight( arr, 0, naryFunction( abs, 2 ), naryFunction( add, 2 ) );
// returns 21
Performs a map-reduce operation for each element in an array while iterating from right to left and returns the accumulated result.
The mapping function is provided four arguments:
The reducing function is provided four arguments:
If provided an empty array, the function returns the initial value.
input array
initial value
mapping function
reducing function
reducing function execution context
accumulated result
function square( value ) {
return value * value;
}
function sum( acc, value ) {
return acc + value;
}
var arr = [ 1, 2, 3, 4 ];
var out = mapReduceRight( arr, 0, square, sum );
// returns 30
Callback invoked for each array element.
array element
element index
array
result