This page is part of a static HTML representation of the TiddlyWiki at https://tiddlywiki.com/

filter Operator

27th October 2020 at 6:51pm
Filter Operators Negatable Operators
purposeapply a subfilter to each input title and return the titles that return a non-empty result from the subfilter
inputa selection of titles passed as input to the filter
! inputa selection of titles passed as input to the filter
parameterS = a filter expression
outputthe selection of titles that pass the filter S
! outputthose input titles that do not pass the filter S

New in: 5.1.23 The filter operator runs a subfilter for each input title, and returns those input titles for which the subfilter returns a non-empty result (in other words the result is not an empty list). The results of the subfilter are thrown away.

Simple filter operations can be concatenated together directly (eg [tag[HelloThere]search[po]]) but this doesn't work when the filtering operations require intermediate results to be computed. The filter operator can be used to filter on an intermediate result which is discarded. To take the same example but to also filter by those tiddlers whose text field is longer than 1000 characters:

<$vars myfilter="[get[text]length[]compare:integer:gteq[1000]]">
<$list filter="[tag[HelloThere]search[po]filter<myfilter>]">
<div>
<$link>
<$text text=<<currentTiddler>>/>
</$link>
</div>
</$list>
</$vars>

Compare with the similar subfilter operator which runs a subfilter and directly returns the results

Compare with the analagous named filter run prefix :filter

\define larger-than-1k() [get[text]length[]compare:integer:gteq[1000]]

{{{ [tag[HelloThere]filter<larger-than-1k>] }}}

is equivalent to:

{{{ [tag[HelloThere]] :filter[get[text]length[]compare:integer:gteq[1000]] }}}

Examples