pauses the enclosing incremental function that yields e.
IncrementalYield
pauses the enclosing incremental function that yields e.
Details
- IncrementalYield can only be used in Function expressions marked with IncrementalFunction.
- Functions in which IncrementalYield appears have to be processed by compiler functions such as FunctionCompile.
- After executing IncrementalYield, the incremental function will save its local variables and return the value to the caller.
- An incremental function that executes IncrementalYield can be woken up with a call to "Next".
Examples
Basic Examples (2)
An incremental function that has one yield:
func = IncrementalFunction@Function[Typed[arg, "MachineInteger"], IncrementalYield[arg + 1];];A CompiledCodeFunction that returns an "IncrementalFunction" data structure:
comp = FunctionCompile[func]Create an instance of the incremental function:
ds = comp[10]Run the incremental function to the IncrementalYield and return the partial result:
ds["Next"]The incremental function has finished, so calling the "Next" operation results in a failure:
ds["Next"]An incremental function that returns a sequence of multiples of its argument:
comp =
FunctionCompile@IncrementalFunction@
Function[Typed[num, "Integer64"],
Module[{mul = num}, While[True, IncrementalYield[mul += num]]]
];An instance of the incremental function that returns multiples of 7:
ds = comp[7]The first result from the incremental function:
ds["Next"]ds["Next"]Table[ds["Next"], 100]A different instance of the incremental function that returns multiples of 17:
ds1 = comp[17]The first 100 multiples of 17:
Table[ds1["Next"], 100]The function that is returning multiples of 7 is still waiting to be woken up and return results:
Table[ds["Next"], 100]See Also
IncrementalFunction Function Typed FunctionCompile FunctionDeclaration IncrementalReceive
Compiled Types: IncrementalFunction
Tech Notes
Related Guides
History
Text
Wolfram Research (2025), IncrementalYield, Wolfram Language function, https://reference.wolfram.com/language/ref/IncrementalYield.html.
CMS
Wolfram Language. 2025. "IncrementalYield." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/IncrementalYield.html.
APA
Wolfram Language. (2025). IncrementalYield. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/IncrementalYield.html
BibTeX
@misc{reference.wolfram_2026_incrementalyield, author="Wolfram Research", title="{IncrementalYield}", year="2025", howpublished="\url{https://reference.wolfram.com/language/ref/IncrementalYield.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_incrementalyield, organization={Wolfram Research}, title={IncrementalYield}, year={2025}, url={https://reference.wolfram.com/language/ref/IncrementalYield.html}, note=[Accessed: 12-June-2026]}