array of arrays
initial values
function to apply
input function context
accumulation results
var naryFunction = require( `@stdlib/utils/nary-function` );
var add = require( `@stdlib/math/base/ops/add` );
var arr = [
[ 1, 2, 3 ],
[ 4, 5, 6 ]
];
var out = reduce2d( arr, [ 0, 0 ], naryFunction( add, 2 ) );
// returns [ 6, 15 ]
Reduces the number of dimensions by one of a two-dimensional nested array by applying a function against an accumulator and each element along the innermost dimension and returning the accumulation results as a one-dimensional array.
Notes
The applied function is provided the following arguments:
the second argument must have a length equal to the size of the outermost input array dimension