10th July 2023 at 7:33am
purpose | replaces all filter output so far with a single item by repeatedly applying a filter run to each input title |
---|---|
input | the filter output of all previous runs so far |
output | the accumulated single item |
Each input title from previous runs is passed to this run in turn. The result of each previous call to this run is made available in the next call via the variable named accumulator
. The result of the last call to this run is returned as the output. A typical use is to add up the values in a given field of each input title.
Replaces all filter output so far with a single item by repeatedly applying a formula, as described above, to each input title.
The following variables are available within the filter run:
accumulator
- the result of the previous filter runcurrentTiddler
- the input title..currentTiddler
- the value of the variablecurrentTiddler
outside the filter run. Introduced in v5.2.0index
- the numeric index of the current list item (with zero being the first item in the list)revIndex
- the reverse numeric index of the current list item (with zero being the last item in the list)length
- the total length of the input list
[tag[shopping]] :reduce[get[quantity]add<accumulator>]
is equivalent to:
\define num-items() [get[quantity]add<accumulator>]
[tag[shopping]reduce<num-items>]