WLJS LogoWLJS Notebook

IncrementalFunction

IncrementalFunction[fun]

represents a compilable function that can pause its execution, preserve its state and resume later.

Incremental functions are processed by compiler functions such as FunctionCompile. They can yield a sequence of partial results without completing.

Example

compiled = FunctionCompile[
  IncrementalFunction[
    Function[
      Typed[n, "Integer64"],
      While[True, IncrementalYield[n]]
    ]
  ]
];

instance = compiled[10];
instance["Next"]

See the official Wolfram Language reference for yielding, receiving and managing active instances.

On this page