Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Python

Idiom #319 Generator function

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

def g():
    for i in range(6):
        yield i
List<int> g(int start) sync* {
  while (true) {
    yield start;
    start++;
  }
}

Infinite lazy list of ints starting from a specific integer

New implementation...
< >
willard