Skip to main content

Reduce

Reduce a list to a single value using a function

Written by Holly Conrad Smith

Reduce is Map's sibling: both run once per item in a list, using the same loop mechanics. The difference is what comes out the other end — Map hands back a new list (one result per item), while Reduce folds everything down into a single running value, carried from one item to the next, and only outputs that final total. Use it whenever the answer you want is one number or one value summarizing a whole list — a total, a maximum, a combined shape — not a list of results.

Category: Data Flow

Kind: Operation

Description: reduce a list to a single value using a function

Inputs

Name

Abbreviation

Type

Access

Description

list

L

Any

List

the list to reduce

return value

R

Any

Item (loop)

wire your computed result here — it becomes the accumulator for the next item

initial value (optional)

I

Any

Item

the starting value for the accumulator — defaults to the list's first item if omitted

Outputs

Name

Abbreviation

Type

Access

Description

result

R

Any

Item

the final reduced value, after every item has been folded in

accumulator

A

Any

Item (loop)

the running value carried over from the previous item

value

V

Any

Item (loop)

the current item being processed

index

I

Number

Item (loop)

the position of the current item

How to

Reduce works on the same canvas as everything else — there's no separate sub-flow screen to open. You wire its "value" and "accumulator" outputs into ordinary nodes, then feed the result of that chain back into Reduce's own "return value" input, the same way you would with Map.

  1. Add the Reduce node and feed your list into "list".

  2. Optionally wire a starting value into "initial value" — if you skip it, the accumulator starts as the list's first item.

  3. From Reduce's "value" and "accumulator" outputs, build whatever calculation combines the current item into the running total.

  4. Wire the result of that calculation back into Reduce's "return value" input — that's the loop-closing wire.

  5. Read "result" off the Reduce node for the final answer, after every item has been folded in.

Example: placing footprints in priority order without overlaps

A plain total or max wouldn't need Reduce — Sum and the Analytics pivots already handle those. Reduce earns its keep when each step depends on everything that came before it, not just its own value. Say you have a prioritized list of candidate building footprints (already sized and positioned) and you want to place them in order, clipping each one against whatever's already been placed so nothing overlaps.

  1. Feed your prioritized list of candidate footprints into Reduce's "list" input.

  2. Set "initial value" to the first footprint in the list, unclipped — nothing's been placed yet, so there's nothing to clip against.

  3. Wire Reduce's "accumulator" output (everything placed so far, as one combined shape) and "value" output (the next candidate footprint) into a Boolean Difference node — candidate minus accumulator — to clip away any part of this candidate that overlaps what's already down.

  4. Feed that clipped result, along with the accumulator, into a Boolean Union node to fold it into the combined "occupied" shape.

  5. Wire the Union node's output back into Reduce's "return value" input — each pass adds one more non-overlapping footprint onto the running total.

  6. Reduce's "result" output is the final combined footprint after every candidate has been placed and clipped, in priority order — something no single built-in aggregate node could do, since each step's outcome depends on every step before it.

The same shape applies to other order-dependent problems — like applying a stack of zoning overlays where each one only tightens the current height limit if it's more restrictive than what's already been applied, rather than just taking the min/max of the raw list.

Did this answer your question?