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