1 | ;
|
2 | function mod(x, y) {
|
3 | return x - y * Math.floor(x / y);
|
4 | }
|
5 | function concat$(x, ...ys) {
|
6 | for (var y of ys)
|
7 | x.push(...y);
|
8 | return x;
|
9 | }
|
10 | function rotate(x, n = 0) {
|
11 | var n = mod(n, x.length);
|
12 | return concat$(x.slice(n), x.slice(0, n));
|
13 | }
|
14 | module.exports = rotate;
|