-
Notifications
You must be signed in to change notification settings - Fork 1
rotate
Subhajit Sahu edited this page May 11, 2020
·
19 revisions
Rotates values in iterable.
array.rotate(x, n);
// x: an array
// n: rotate amount (-ve: left, +ve: right)
const iterable = require('extra-iterable');
var x = [1, 2, 3, 4];
[...iterable.rotate(x, 1)];
// [ 4, 1, 2, 3 ]
[...iterable.rotate(x, -1)];
// [ 2, 3, 4, 1 ]
[...iterable.rotate(x, -2)];
// [ 3, 4, 1, 2 ]