5th March 2023 at 12:54pm
The following examples use these 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[get[quantity]add<accumulator>]
[tag[shopping]] :reduce[get[price]multiply{!!quantity}add<accumulator>]
[tag[shopping]] :reduce[<index>compare:number:gt[0]then<accumulator>addsuffix[, ]addsuffix<currentTiddler>else<currentTiddler>]
<index>
to act differently on the first item than the rest. Just for demonstration. Better to use the join Operator to accomplish this task[tag[non-existent]] :reduce[get[price]multiply{!!quantity}add<accumulator>]
[tag[non-existent]] :reduce[get[price]multiply{!!quantity}add<accumulator>] :else[[0]]
:else
to ensure output if input was empty=1 =2 =3 :reduce[multiply<accumulator>]
=1 =2 =3 +[reduce<multiply-input>,[1]]