Hi Eric,

 Thank you for sharing!

 Looking in TW-Scripts you can find two great resources for working with 
filters:


   - Jed Carty: https://ooktech.com/jed/ExampleWikis/FilterLogicExamples/
   - Tobias Beer: https://tobibeer.github.io/tw/filters/#Filter%20Examples


 
and I alos would like to add the great interactive playground by Eric 
Shulman
http://tiddlytools.com/filtergenerators.html


These are three wonderful sources for learning filters and of course the 
holly TW-Scripts :-) :-)

--Mohammad


On Wednesday, May 6, 2020 at 3:44:52 PM UTC+4:30, Eric N. wrote:
>
> I was stuck in my dev 
> <https://groups.google.com/forum/#!topic/tiddlywiki/H90XO43PblE> because 
> I couldn't output the intersection of two filters, each made of several 
> runs. I didn't find a built-in function to do so, and I couldn't find a 
> satisfying solution online. But I eventually found my own solution, shared 
> here.
>
> Say I want to get all the tiddlers that satisfy the following conditions 
> (toy example here, could also have a pair of very complex filters):
>
> (has tag Todo OR starts with "a") AND (has tag Howto OR starts with "al")
>
> This is computed by the following code, where the output list is enlist
> <setAinterB>, which is displayed by the list-links macro.
>
> <$set name="filterA" filter="[tag[Todo]] [all[]prefix[a]]">
> <$set name="filterB" filter="[tag[Howto]] [all[]prefix[al]]">
> <$set name="setAunionB" filter="[enlist<filterA>] [enlist<filterB>]">
> <$set name="setAnotB" filter="[enlist<filterA>] -[enlist<filterB>]">
> <$set name="setBnotA" filter="[enlist<filterB>] -[enlist<filterA>]">
> <$set name="setAinterB" filter="[enlist<setAunionB>] -[enlist<setAnotB>] 
> -[enlist<setBnotA>]">
>
> <<list-links "[enlist<setAinterB>sort[]]">>
>
> </$set>
> </$set>
> </$set>
> </$set>
> </$set>
>
>
> *Caveat* : if a filter output contains double brackets (say a tiddler 
> named "oh what a [[bad]] name") it breaks the enlist processing, and you 
> won't have the correct output.
>
>
> Best,
> Eric
>

-- 
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/b935517c-d1fd-4372-8553-8db5edd0f4fa%40googlegroups.com.

Reply via email to