created: 20210618133745003 from-version: 5.3.0 modified: 20230506172920710 rp-input: <<.olink all>> tiddler titles rp-output: the output of this filter run replaces the output of previous runs unless it is an empty list (see below) rp-purpose: replace any input to this filter run with its output, only evaluating the run when there is any input search: tags: [[Filter Run Prefix]] [[Filter Syntax]] title: Then Filter Run Prefix type: text/vnd.tiddlywiki \define .op-row() <$macrocall $name=".if" cond="""$(op-body)$""" then="""$(op-head)$<<.op-place>>$(op-body)$""" else=""/> \end <$list filter="[all[current]has[from-version]]" variable="listItem"> <$macrocall $name=".from-version" version={{!!from-version}}/> <$let op-head="" op-body="" op-name=""> <$let op-head="purpose" op-body={{!!rp-purpose}}> <<.op-row>> <$let op-head="[[input|Filter Expression]]" op-body={{!!rp-input}}> <<.op-row>> <$let op-head="suffix" op-body={{!!rp-suffix}} op-name={{!!rp-suffix-name}}> <<.op-row>> <$let op-head="output" op-body={{!!rp-output}}> <<.op-row>>
<$railroad text=""" \start none \end none ":then" [[run|"Filter Run"]] """/> !Introduction The <<.op :then>> filter run prefix is used to replace the result of all previous filter runs with its output. If the result of all previous runs is an empty list, the <<.op :then>> prefixed filter run is not evaluated. If the output of a <<.op :then>> prefixed filter run is itself an empty list, the result of all previous filter runs is passed through unaltered. <<.tip "Note that a list with a single empty string item is not an empty list.">> !! <<.op :then>> run prefix versus the <<.olink then>> operator The major difference between the <<.op then>> operator and a <<.op :then>> prefixed filter run is that the operator will replace //each item// of the input [[Title List]] with its parameter while <<.op :then>> will replace the //whole input list// with the result of its run. |doc-op-comparison tc-center|k | !<<.op :then>> Filter Run Prefix | !<<.op then>> Operator | |^<<.operator-example m1-1 "[tag[WikiText]] :then[[true]]">>|^<<.operator-example m1-2 "[tag[WikiText]then[true]]">>

To make them equivalent, additional filter steps may be added:

<<.operator-example m1-3 "[tag[WikiText]count[]compare:number:gt[0]then[true]]">>| ! [[Examples|Then Filter Run Prefix (Examples)]]