nstatistics
Version:
Solve equations using numerical methods, linear álgebra and solver of linear equation system
19 lines (17 loc) • 380 B
JavaScript
;
function sum( j, n, map ) {
var _sum = 0;
for ( var i = j; i <= n; i++ ) {
_sum += map( i );
}
return _sum;
}
module.exports = function ( j, n, map, cb ) {
if ( cb && typeof cb === 'function' ) {
setImmediate( function ( ) {
cb( sum( j, n, map ) );
} );
} else {
return sum( j, n, map );
}
};