Logo

Programming-Idioms

  • Obj-C

Idiom #319 Generator function

Write a function g that behaves like an iterator.
Explain if it can be used directly in a for loop.

List<int> g(int start) sync* {
  while (true) {
    yield start;
    start++;
  }
}

Infinite lazy list of ints starting from a specific integer

New implementation...
< >
willard