-
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. 🏃 📼 📦 🌔 📒
iterable.rotate(x, [n]);
// x: an iterable
// n: rotate amount (-ve: left, +ve: right) (0)
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 ]