Reduce

Combines the elements of an array into one value.

Node id array/reduce

The Reduce node goes through array one element at a time, keeping a running value (the accumulator): it starts from initial, each call of function gives the next one, and the last one is the result. Summing numbers, or finding the largest shape, are reductions.

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

Inputs

NameTypeDefaultNotes
arrayArray<T>—generic
initialA—generic
functionFunction(A, T, number, ...) -> (A)—generic
argumentsX—multigenericindependent

Outputs

NameTypeNotes
resultAgeneric

Behaviour

  • The function has the type Function(A, T, number, ...) -> (A): it gets the accumulator, the element and its index, and gives the new accumulator. See Functions.
  • The accumulator's type comes from initial and the function, and needn't be the element type: reducing an array of circles can give a number.
  • Extra arguments. Values connected to arguments (a multi input) are passed to every call after the index, in slot order, as for Map.
  • An empty array gives initial, without calling the function.
  • Each call is separate, with its own random numbers.

Errors

  • 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 the function fails for any element, Reduce fails.
© 2026 Wirepaint