Charlie,

For more good fun, I wondered if the dynamic filter part of your solution
could be implemented using the new filter features of 5.2.0. Here's what I
came up with that seems to work:

[fields[]regexp[aaa]] :map[all[tiddlers]get<currentTiddler>sum[]] +[sum[]]


or to match your output:

''total:'' <$text text={{{ [fields[]regexp[aaa]]
:map[all[tiddlers]get<currentTiddler>sum[]] +[sum[]] }}}/>


Brian

On Thu, Dec 16, 2021 at 10:28 AM Charlie Veniot <[email protected]> wrote:

> *Dynamic creation of filters !!!*
>
> Say that one has an untold number of numeric fields spread throughout a
> TiddlyWiki instance, all of those fields having names that match a pattern.
>
> (For example: say all of the fields have "aaa" in their names.)
>
> And say any one tiddler can have an untold number of those fields (0 to
> many).
>
> How would we go about summing all of these fields, specifying only a
> pattern for field names, and without knowing which tiddlers have those
> fields?
>
> As an exercise, here's my approach.  Download attached and drag into
> TiddlyWiki.com for study.
>
> For convenience, here is the code of interest:
>
> <pre>
>
> \define p1() [get[
> \define p2() ]]
> \define p3() +[sum[]]
>
> <$list variable="thisField" filter="[fields[]regexp[aaa]]">
> sum of <<thisField>> values:
> <$list filter="[get<thisField>sum[]]">
> {{!!title}}
> </$list><br>
> </$list>
> *<$vars thisDynamicFilter={{{
> [fields[]regexp[aaa]addprefix<p1>addsuffix<p2>] [<p3>] +[join[ ]] }}}>*
> <$list filter={{{ *[<thisDynamicFilter>]* }}}>
> ''total:'' <<currentTiddler>>
> </$list>
> </$vars>
>
> </pre>
>
> Good fun !
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "TiddlyWiki" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/tiddlywiki/cc29ad8a-6b8e-43b9-889e-98761cd86532n%40googlegroups.com
> <https://groups.google.com/d/msgid/tiddlywiki/cc29ad8a-6b8e-43b9-889e-98761cd86532n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/CAO5X8Cxtm9mRZ0YV2ShKDT-LA0utJfkZ2nGtizindHibv7dJrQ%40mail.gmail.com.

Reply via email to