Repeat

Applies a function to its own result, again and again.

Node id core/repeat

The Repeat node keeps a state: it starts from initial, and each call of function gives the next state and whether to go on. It outputs the last state. Use it for step-by-step processes where each step builds on the previous one, such as a random walk or a growing pattern.

The function is a subgraph. To make one that fits, drag a wire from Repeat's function input onto empty canvas and choose New function…, or right-click Repeat and choose New function….

Inputs

NameTypeDefaultNotes
initialT—generic
functionFunction(T, number, ...) -> (T, boolean)—generic
maxIterationsnumber100
argumentsA—multigenericindependent

Outputs

NameTypeNotes
stateTgeneric

Behaviour

  • The function has the type Function(T, number, ...) -> (T, boolean): it gets the state and the iteration number (0 for the first call), and gives the new state and continue. See Functions.
  • Stopping. Repeat stops when the function gives continue = false (the state from that call is kept), or after maxIterations calls, whichever comes first. maxIterations defaults to 100.
  • No calls. With maxIterations = 0, the output is initial.
  • Extra arguments. Values connected to arguments (a multi input) are passed to every call after the state and iteration, in slot order. Each slot may have its own type.
  • Each call is separate, with its own random numbers.

Errors

  • maxIterations must be a whole number from 0 to 10 000. The cap keeps a graph from looping (nearly) forever.
  • function must be connected.
  • The function must take exactly as many extra parameters as there are arguments, each of the right type, checked before any call.
  • If any call of the function fails, Repeat fails.
  • Map: calls a function once per element of an array.
  • Reduce: carries a state through an array.
© 2026 Wirepaint