Skip to content

@lang:reduce

Reduce an array to a single value by applying a helper.

On-chain (@lang:reduce!): Accumulator comes first. Generic values and repeated accumulators accept composed ABI-typed definitions; word folds also accept associative operator names.

Returns: any

@lang:reduce(arr fn initial)
NameTypeDescription
arrarraySource array
fnhelperReducer helper receiving (accumulator, element)
initialanyInitial accumulator value
  • @map — transform each element
  • @filter — keep elements by predicate

Fold left with the accumulator as the first callback parameter and the element as the second. Named callbacks can compose helpers and ABI calls over typed values; their output must match the accumulator type. Bare operator names remain available for supported word reductions.