Generators
Iterable<int> naturalsTo(int n) sync* {
int k = 0;
while (k < n) yield k++;
}Stream<int> asynchronousNaturalsTo(int n) async* {
int k = 0;
while (k < n) yield k++;
}Iterable<int> naturalsDownFrom(int n) sync* {
if (n > 0) {
yield n;
yield* naturalsDownFrom(n - 1);
}
}Last updated