Generator/Exponential: Difference between revisions

Content added Content deleted
m (added a ;Task: section header, added whitespace to the task's preamble, added whitespace before the table-of-contents (TOC).)
Line 3: Line 3:
[[Category:Non parametric generators]]
[[Category:Non parametric generators]]
[[Category:Stateful transactions]]
[[Category:Stateful transactions]]

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.
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 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.
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.


'''Task description'''


;Task:
# Create a function that returns a generation of the m'th powers of the positive integers starting from zero, in order, and without obvious or simple upper limit. (Any upper limit to the generator should not be stated in the source but should be down to factors such as the languages natural integer size limit or computational time/size).
# Create a function that returns a generation of the m'th powers of the positive integers starting from zero, in order, and without obvious or simple upper limit. (Any upper limit to the generator should not be stated in the source but should be down to factors such as the languages natural integer size limit or computational time/size).
# Use it to create a generator of:
# Use it to create a generator of:
Line 19: Line 22:
'''See also'''
'''See also'''
* [[wp:Generator (computer_science)|Generator]]
* [[wp:Generator (computer_science)|Generator]]
<br><br>


=={{header|Ada}}==
=={{header|Ada}}==