이 문서는 https://tiddlywiki.com/languages/ko-KR/에서 티들리위키의 정적 HTML 표현의 일부입니다

reduce Operator (Examples)

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:

[tag[shopping]reduce<num-items>]

[tag[shopping]reduce<add-price>]

[tag[shopping]reduce<join-with-commas>]
→ Uses <index> to act differently on the first item than the rest

[tag[non-existent]reduce<add-price>]
→ Empty input produces empty output

[tag[non-existent]reduce<add-price>else[0]]
→ Use else to ensure output if input was empty

=1 =2 =3 +[reduce<multiply-input>]
→ Empty initial value is treated as 0 by mathematical operators

=1 =2 =3 +[reduce<multiply-input>,[1]]
→ Setting initial value is sometimes necessary for correct results