-
Notifications
You must be signed in to change notification settings - Fork 5
cycle
Subhajit Sahu edited this page May 3, 2023
·
20 revisions
Obtain values that cycle through array.
function cycle(x, i, n)
// x: an array
// i: begin index [0]
// n: number of values [|x|]
const xarray = require('extra-array');
var x = [1, 2, 3];
xarray.cycle(x, 0, 2);
// → [ 1, 2 ]
xarray.cycle(x, 0, 4);
// → [ 1, 2, 3, 1 ]
xarray.cycle(x, 1, 6);
// → [ 2, 3, 1, 2, 3, 1 ]