Inclusive filter operator

98 views
Skip to first unread message

Mohammad

unread,
Jan 23, 2020, 12:20:24 PM1/23/20
to TiddlyWiki
Which Tiddlywiki operator is inclusive?

By inclusive I mean all the input titles meet the filter conditions.

For example I want to check if all tiddlers tagged with myTag has the word xx in their title?
Or  check if all tiddlers tagged with myTag has the field myfield?

So the filter is empty if only one input title does not match the criteria.

<$list filter="[tag[myTag]has[myfield]??"> ...



In the same manner we can think about any filter. This now works by limit[1]  means if only one input title meets the criteria!


--Mohammad

Joshua Fontany

unread,
Jan 23, 2020, 10:22:21 PM1/23/20
to TiddlyWiki
Mohammad,

Hi! Eric and Thomas came up with a neat trick, let me dig it up. You will want the new Search filter operator (it can take a regexp argument and thus 'replaces' the old regexp operator).

You will want to chain the operators and then test for equality by 'minusing' one of the counts from the other. If they are equal, then the "emptyMessage" is rendered. If theey are not equal, then a single item with the Count variable is rendered...

`<$list filter="[tag[myTag]count[]] -[tag[myTag]search:title,tag,caption:regexp[myTerm]count[]]" emptyMessage="TRUE">

FALSE

Mohammad

unread,
Jan 24, 2020, 1:07:00 AM1/24/20
to TiddlyWiki
Hi Joshua,
 Thank you! Yes this is a solution albeit it is indirect!

So, I understood there is not a direct inclusive all operator to these cases!

Some use cases are
  • delete a field if and only if all have that field
  • display list of title, if and only if all have modified today
  • change the caption to green if and only if all have non-empty caption

--Mohammad

TonyM

unread,
Jan 26, 2020, 5:25:08 PM1/26/20
to TiddlyWiki
Mohammad,

I am not so sure how to read your requirement, here are some ideas, I may have it wrong.

I will be honest, I got very confused. Could you give a more extensive real world example eg;
tiddler = person
tag = invited (to the party)
Test 1 = Paid entry fee (required)
Test 2 = Wearing a suit (required)

If just one person has not paid, or wearing a suit then NO PARTY

but are you saying;

Given a Filter that results in a list of tiddlers, return nothing if even one fails to pass a second or third filter?

Your Question seems to ask

[tag[myTag]] has the word xx in their title
OR
[tag[myTag]] has the field myfield
But then you say So the filter is empty if only one input title does not match the criteria.

I would think this we inclusive, To get them into the save filter you need to generate [tag[myTag]] list twice
[tag[myTag]word xx in their title] [tag[myTag]the field myfield]

[tag[myTag]contains:title[xx]] [tag[myTag]has:field[myfield]]

This will generate a list of tiddlers that meet one OR both criteria
The OR is implied by the space making this two "filter runs"

But perhaps what you are asking is
  • The filter is empty if only one input title "[tag[myTag]]" does not match the criteria [tag[myTag]contains:title[xx]] OR [tag[myTag]has:field[myfield]] return nothing
  • This means in effect if any (1 or more) tiddlers do NOT match both criteria, return nothing.

If I understand this correctly you are asking
  • Give me a list of [tag[myTag]] tiddlers
  • Test if any do not meet the criteria
If we ask

[tag[myTag]count[]]
We find out how many are eligible


[tag[myTag]] +[contains:title[xx]] +[tag[myTag]has:field[myfield]] +[count[]]
we find out how many passed the criteria

  • For all tiddlers [tag[myTag]]
  • Include tiddlers that contain title XX AND include field[myfield]
  • The result will be a list of complying tiddlers
  • +[Count[]] will count them and give us the number that comply
A final comparison to see if the eligible are more than those that comply 


Not sure!
Sharing my notes in full should it provide insight.

Regards
Tony

Mohammad Rahmani

unread,
Jan 26, 2020, 9:26:08 PM1/26/20
to tiddl...@googlegroups.com
Hi Tony,

On Mon, Jan 27, 2020 at 1:55 AM TonyM <anthony...@gmail.com> wrote:
Mohammad,

I am not so sure how to read your requirement, here are some ideas, I may have it wrong.

I will be honest, I got very confused. Could you give a more extensive real world example eg;
tiddler = person
tag = invited (to the party)
Test 1 = Paid entry fee (required)
Test 2 = Wearing a suit (required)

If just one person has not paid, or wearing a suit then NO PARTY

but are you saying;

Given a Filter that results in a list of tiddlers, return nothing if even one fails to pass a second or third filter?

Your Question seems to ask

[tag[myTag]] has the word xx in their title
OR
[tag[myTag]] has the field myfield
But then you say So the filter is empty if only one input title does not match the criteria.

Yep, all tiddlers shall meet the criteria, if only one fails, then return empty!


I would think this we inclusive, To get them into the save filter you need to generate [tag[myTag]] list twice
[tag[myTag]word xx in their title] [tag[myTag]the field myfield]

[tag[myTag]contains:title[xx]] [tag[myTag]has:field[myfield]]

This will generate a list of tiddlers that meet one OR both criteria
The OR is implied by the space making this two "filter runs"


NO, this is OR and what I asked is AND.
For example if all tiddlers have a field X do some operation IF only one has not, then ignore whole operation.
One real case, Set the color to red if all tiddlers filtered have the field color!
I know with complex filter operation it is possible to get this in work!
But I am looking for a filter operator to this simply and semantically

But perhaps what you are asking is
  • The filter is empty if only one input title "[tag[myTag]]" does not match the criteria [tag[myTag]contains:title[xx]] OR [tag[myTag]has:field[myfield]] return nothing
  • This means in effect if any (1 or more) tiddlers do NOT match both criteria, return nothing.

If I understand this correctly you are asking
  • Give me a list of [tag[myTag]] tiddlers
  • Test if any do not meet the criteria
If we ask

[tag[myTag]count[]]
We find out how many are eligible


[tag[myTag]] +[contains:title[xx]] +[tag[myTag]has:field[myfield]] +[count[]]
we find out how many passed the criteria

  • For all tiddlers [tag[myTag]]
  • Include tiddlers that contain title XX AND include field[myfield]
  • The result will be a list of complying tiddlers
  • +[Count[]] will count them and give us the number that comply
A final comparison to see if the eligible are more than those that comply 


Not sure!
Sharing my notes in full should it provide insight.

In simple words: do an operation on a set of filtered tiddlers if and only if ALL of them pass some crteria

if all tiddlers have a caption, then set it
if all tiddlers have a color field, then set it to red
...

 

Regards
Tony



On Friday, January 24, 2020 at 4:20:24 AM UTC+11, Mohammad wrote:
Which Tiddlywiki operator is inclusive?

By inclusive I mean all the input titles meet the filter conditions.

For example I want to check if all tiddlers tagged with myTag has the word xx in their title?
Or  check if all tiddlers tagged with myTag has the field myfield?

So the filter is empty if only one input title does not match the criteria.

<$list filter="[tag[myTag]has[myfield]??"> ...



In the same manner we can think about any filter. This now works by limit[1]  means if only one input title meets the criteria!


--Mohammad

--
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 tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/453da2bb-e054-4d4b-8ee1-1c76663259ac%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages