Map Graph
No coordinates found

Generator (computer programming)

Routine that generates a sequence of values

In computer science, a generator is a routine that can be used to control the iteration behaviour of a loop. All generators are also iterators. A generator is very similar to a function that returns an array, in that a generator has parameters, can be called, and generates a sequence of values. However, instead of building an array containing all the values and returning them all at once, a generator yields the values one at a time, which requires less memory and allows the caller to get started processing the first few values immediately. In short, a generator looks like a function but behaves like an iterator.

Read article
Top Questions
AI generated

List the top facts about Generator (computer programming)

Summarize this article

What is the single most intriguing fact about Generator (computer programming)?

Are there any controversies surrounding Generator (computer programming)?

More questions