On Wednesday, 19 December 2018 23:21:15 UTC+1, Jeremy Ruston wrote: > > Hi Joe > > Then a filter that finds A is "[tag[A]]" > > B OR C is "[tag[B]] [tag[C]]" > > A AND B is "[tag[A]tag[B]]" > > A and (B or C) has to be rewritten as > (A and B) or (A and C) and is > > "[tag[A]tag[B]] [tag[A]tag[C]]” > > > You can directly do A and (B or C) as: > > [tag[B]] [tab[C]] +[tag[A]] > > There are three runs here: > > * The first two are processed in the same way: they start with an implicit > [all[tiddlers]] to select all “real” tiddlers (ie, non-shadow tiddlers), > whether or not they are system tiddelrs. The [tag[x]] filter operator > selects those tiddlers that carry the indicated tag. At the end of > processing each run, the results of the run are merged into the > accumulator, the temporary holding storage for intermediate results. > > * The third run starts with a “+” which means that instead of kicking off > with all the real tiddlers, it instead uses the accumulator as the input to > the run. The [tag[A]] then selects those tiddlers from the accumulator that > carry the tag “A”. > > The results of the third run replace the accumulator, and become the > results of the entire filter. >
Great - IMHO the above explanation is far better than the definitive explanation https://tiddlywiki.com/#Filter%20Expression So the algorithm is 1) create an empty output set (call this accumulator) 2) A <whitespace> B means starting from the set of all tiddlers add those that match A to accumulator starting from the set of all tiddlers add those that match B to accumulator 3) +X means starting from the accumulator match all X's and create a NEW accumulator which is passed onto the next step So A B +C where A B and C are "runs" means (in pseudo code) accumulator = {} // empty set accumulator += matchalltags oftype A from all tiddlers accumulator += matchalltags oftype B from all tiddlers accumulator1 = matchalltags oftype C from accumulator return accumulator1 > The other filter prefixes that are available are “-“ and “~”. The action > of minus is that the results of the run are removed from the accumulator > (the input to the run is still the list of all “real” tiddlers). The action > of tilde is to only evaluate the run if the accumulator is empty; the > results of the run then become the accumulator. > > Which in a strange way reminds me of horn clauses in Prolog where I'd > write: > > ``` > filter(a, b) :- ... > filter(a, c) :- .. > ``` > > So really these filter expressions are equivalent to queries in predicate > logic. > > (which is why they are so powerful :-) > > > Thank you! It’s slightly embarrassing to have to invent something rather > than being able to adopt something tried and trusted, so it’s good to hear > that it’s not too terrible. > > You've invented the monad :-) - monads just pass an invisible state through a pipeline of operations that manipulate the state (you call it an accumulator) Cheers /Joe > Best wishes > > Jeremy > > > Cheers > > /Joe > > > > -- > You received this message because you are subscribed to the Google Groups > "TiddlyWikiDev" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to tiddlywikide...@googlegroups.com <javascript:>. > To post to this group, send email to tiddly...@googlegroups.com > <javascript:>. > Visit this group at https://groups.google.com/group/tiddlywikidev. > To view this discussion on the web visit > https://groups.google.com/d/msgid/tiddlywikidev/9b8edbb1-8657-4502-ba5e-c867651203a4%40googlegroups.com > > <https://groups.google.com/d/msgid/tiddlywikidev/9b8edbb1-8657-4502-ba5e-c867651203a4%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > > > -- You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group. To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywikidev+unsubscr...@googlegroups.com. To post to this group, send email to tiddlywikidev@googlegroups.com. Visit this group at https://groups.google.com/group/tiddlywikidev. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywikidev/730d567c-c1a1-4d26-afac-38f0148b635c%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.