Reduce (Expression) — Skript

Addon: Skript · Category: Expression · Since: 2.15

Syntax

%objects% (reduced|folded) (to|with|by) \[<.+>\]

Description

Reduces lists to single values by repeatedly applying an operation. The reduce expression takes each element and combines it with an accumulator value. Use 'reduced value' to access the current accumulated value and 'input' for the current element.

Examples

set {_sum} to {_numbers::*} reduced with [reduced value + input]
set {_product} to {_values::*} reduced with [reduced value * input]
set {_concatenated} to {_strings::*} reduced with ["%reduced value%%input%"]

View source