2020년 12월 4일 오후 1:11
These examples use the following predefined variables:
- add-price:
[get[price]multiply{!!quantity}add<accumulator>]
- num-items:
[get[quantity]add<accumulator>]
- join-with-commas:
[<index>compare:number:gt[0]then<accumulator>addsuffix[, ]addsuffix<currentTiddler>else<currentTiddler>]
- multiply-input:
[multiply<accumulator>]
They also use the following data tiddlers:
- Brownies quantity: 1, price: 4.99
- Chick Peas quantity: 5, price: 1.32
- Milk quantity: 12, price: 0.46
- Rice Pudding quantity: 4, price: 2.66
[tag[shopping]reduce<num-items>]
[tag[shopping]reduce<add-price>]
[tag[shopping]reduce<join-with-commas>]
<index>
to act differently on the first item than the rest[tag[non-existent]reduce<add-price>]
[tag[non-existent]reduce<add-price>else[0]]
else
to ensure output if input was empty=1 =2 =3 +[reduce<multiply-input>]
=1 =2 =3 +[reduce<multiply-input>,[1]]