Generator/Exponential

From Rosetta Code
Revision as of 13:46, 22 November 2010 by rosettacode>Dkf (Wrote a draft task on generators)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Generator/Exponential is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.

A generator is an executable entity (like a function or procedure) that contains code that yields a sequence of values, one at a time, so that each time you call the generator, the next value in the sequence is provided. Generators are often built on top of coroutines or objects so that the internal state of the object is handled “naturally”. Generators are often used in situations where a sequence is potentially infinite, and where it is possible to construct the next value of the sequence with only minimal state.

See also:

Task: Write a generator (or generators), in the most natural way in your language, that produces the numbers that are squares () but not cubes () and use that to print the first 20 members of that sequence.