-
Notifications
You must be signed in to change notification settings - Fork 5
exclusiveScan$
Subhajit Sahu edited this page May 3, 2023
·
1 revision
Perform exclusive prefix scan from left to right!
Alternatives: exclusiveScan, exclusiveScan$.
Similar: inclusiveScan, exclusiveScan.
function exclusiveScan$(x, fr, acc)
// x: an array (updated!)
// fr: reduce function (acc, v, i, x)
// acc: initial value
const xarray = require('extra-array');
var x = [1, 2, 3, 4, 5];
xarray.exclusiveScan$(x, (acc, v) => acc+v, 0); x;
// → [ 0, 1, 3, 6, 10 ] (x modified!)
var x = [1, 2, 3, 4, 5];
xarray.exclusiveScan$(x, (acc, v) => acc+v, 10); x;
// → [ 10, 11, 13, 16, 20 ] (x modified!)