I’ve just implemented a simple fizzbuzz lister:
\define fizzbuzz()
<$let
f3="[remainder[3]match[0]then[fizz]else[]]"
f5="[remainder[5]match[0]then[buzz]else[]]">
<$list variable=num filter="[range[100]]">
<$set name=numfizz filter="[<num>subfilter<f3>]">
<$set name=numbuzz filter="[<num>subfilter<f5>]">
<$set name=numfizzbuzz filter="[<numfizz>addsuffix<numbuzz>!is[blank]else<num>]">
<<numfizzbuzz>><br>
</$set></$set></$set>
</$list>
</$let>
\end
<<fizzbuzz>>
The output is something like “1 2 fizz 4 buzz fizz 7 8 fizz buzz 11 fizz 13 14 fizzbuzz 16 17 fizz 19 buzz fizz 22 (…)”
That’s all and dandy but what about if I want this output a list within a filter for further computing? This fuzzbizz is just a simple example for cases where something trivial via list widget is not trivial without it…
I could use a temporary tiddler and store each of my values within it in the $list loop (and retrieve the whole dictionary afterward, getting my list within a filter), but this would not work if not executed in the context of a button click so it’s not what I want.
For the price of more complex subfilters and by using :map, I could transform the initial list of numbers “num” into list of things like0 “num,fizzy” then “num,fizzy,buzzy” then finally fizzbuzzy but that would be far from ideal and nice. (examples: 15 → 15,fizz → 15,fizz,buzz → fizzbuzz or 37 → 37, → 37, → 37 or 78 → 78,fizz → 78,fizz, → fizz)
Any ideas?