rotate method

Iterable<T> rotate([
  1. int n = 1
])

Implementation

Iterable<T> rotate([int n = 1]) sync* {
  var it = iterator;
  final int l = length;
  int c = 0;
  while (c < n % l) {
    it.moveNext();
    c++;
  }
  while (it.moveNext()) {
    yield it.current;
  }
  it = iterator;
  it.moveNext();
  c = 0;
  while (c < n % l) {
    yield it.current;
    c++;
    it.moveNext();
  }
}