list operator and + prefix

69 views
Skip to first unread message

Mohammad

unread,
Dec 20, 2019, 5:19:46 AM12/20/19
to TiddlyWiki
  1. There are two tiddlers sample and population
  2. the population tiddler has a list field with a b c as field value
  3. the sample tiddler has a list field with only b as field value

Using the below AND run ([filter1]+[filter2]) results in different results why the AND should return the same result


Test

<$list filter="[list[sample]]+[list[population]]">


</$list>


---


<$list filter="[list[population]]+[list[sample]]">


</$list>


Will results in

a
b
c
b
---
b

Why the results are different?

--Mohammad


TonyM

unread,
Dec 20, 2019, 5:42:27 AM12/20/19
to TiddlyWiki
Mohammad

The its not quite an and without parentheses.

[list[sample]] +[list[population]]

The give the results I expect because the + and - prefixes operate on the list fed to it so far.


[list[sample]] [list[population]]

Would give you the content of both lists after removing duplicates. This is I think more like the and you perceive.

The plus says members of first list and tests each title and passes only titles that are also found in the second list.

Using a negative would say list members of the first list but remove those in the second list ie do not pass on those found in the second list.

This is in part due to the filter nature each run follows the previous one and acts on the result of the previous run if you use - + or ~

Filters typically reduce the set first presented to a subset according to its conditions.

For this reason the order is esentiial because one is the source the second is an operation ibn the members in the source.

On way to look at is the second list has a leading operator so it will perform an operation on the list so far.

Regards
Tony

Mohammad

unread,
Dec 20, 2019, 5:56:22 AM12/20/19
to TiddlyWiki


On Friday, December 20, 2019 at 2:12:27 PM UTC+3:30, TonyM wrote:
Mohammad

The its not quite an and without parentheses.

[list[sample]] +[list[population]]

The give the results I expect because the + and - prefixes operate on the list fed to it so far.


[list[sample]] [list[population]]

Would give you the content of both lists after removing duplicates. This is I think more like the and you perceive.

The plus says members of first list and tests each title and passes only titles that are also found in the second list.


This is correct! So why the first part returns all tiddlers in [list[population]]??
It should return only b which is the result of first run and IS found in the second run!!
Message has been deleted

Mohammad

unread,
Dec 20, 2019, 6:47:37 AM12/20/19
to TiddlyWiki
I think to see if there are common tiddlers in two tiddlers list field one needs to use the contain operator

TiddlyTweeter

unread,
Dec 20, 2019, 6:57:20 AM12/20/19
to TiddlyWiki
Mohammad wrote:
It seams I don't know how list works or it is a bug

It is a problem with list filters sometimes working out IF an issue is a bug OR lack of understanding.

In theory it should be possible to present a logical table of filter operations showing scope?
But perhaps not? Not sure! But I have never seen one.

What I have noticed is that skilled programmers too have trouble sometimes with list filters.

I am not a programmer and my approach to list filters is largely "stab-in-the-dark".

Just notes
TT

TonyM

unread,
Dec 20, 2019, 7:52:44 AM12/20/19
to TiddlyWiki
Folks

I will give a better comment at my desktop tomorrow.

Each run with selection modifiers and selection constructors are interpreted sequentially and also alter the result. Its more like the dos or Linux filters such as pipe input and output.

For example we can't use parenthesis to change order as we can in maths.

Its just a different way to conceptualize it and filters are well suited to handling sets (of titles).

I think a conceptual overview would help that I am now more qualified to write than I was before.

Regards
Tony

PMario

unread,
Dec 20, 2019, 7:55:59 AM12/20/19
to tiddl...@googlegroups.com
On Friday, December 20, 2019 at 12:57:20 PM UTC+1, TiddlyTweeter wrote:
...
What I have noticed is that skilled programmers too have trouble sometimes with list filters.

That's true. As it is now, the "filter syntax" is growing into a "DSL" Domain Specific Language. It started with some basic features, that where needed to create the TW UI.

The full V5.1.0 list looked like this:

Filter Formal Grammar
  • FilterOperator: after
  • FilterOperator: all
  • FilterOperator: backlinks
  • FilterOperator: before
  • FilterOperator: bf
  • FilterOperator: butfirst
  • FilterOperator: butlast
  • FilterOperator: commands
  • FilterOperator: each
  • FilterOperator: eachday
  • FilterOperator: field
  • FilterOperator: first
  • FilterOperator: get
  • FilterOperator: has
  • FilterOperator: indexes
  • FilterOperator: is
  • FilterOperator: last
  • FilterOperator: limit
  • FilterOperator: links
  • FilterOperator: list
  • FilterOperator: listed
  • FilterOperator: modules
  • FilterOperator: moduletypes
  • FilterOperator: next
  • FilterOperator: nsort
  • FilterOperator: nsortcs
  • FilterOperator: nth
  • FilterOperator: plugintiddlers
  • FilterOperator: prefix
  • FilterOperator: previous
  • FilterOperator: regexp
  • FilterOperator: removeprefix
  • FilterOperator: removesuffix
  • FilterOperator: rest
  • FilterOperator: reverse
  • FilterOperator: sameday
  • FilterOperator: search
  • FilterOperator: shadowsource
  • FilterOperator: sort
  • FilterOperator: sortcs
  • FilterOperator: suffix
  • FilterOperator: tag
  • FilterOperator: tagging
  • FilterOperator: tags
  • FilterOperator: title
  • FilterOperator: untagged

... It is an "organically grown" language. That means, whenever there was a strong demand, which made sense, something has been implemented, that solved the specific problem.

On the way, some "syntax" decisions had to be made. Sometimes it turned out (after a year or 2), that "the other possibility" would have been better, in the long run. That's why the filter syntax isn't 100% consistent. ... Because ...

Backwards compatibility trumps consistency!! - always

As a result our "filter language" is a little bit more complex, as it could be ;)

just some thoughts.
mario


TiddlyTweeter

unread,
Dec 20, 2019, 9:34:00 AM12/20/19
to TiddlyWiki
PMario wrote:
... It is an "organically grown" language. That means, whenever there was a strong demand, which made sense, something has been implemented, that solved the specific problem. 

... That's why the filter syntax isn't 100% consistent. ... Because ... Backwards compatibility trumps consistency!! - always

As a result our "filter language" is a little bit more complex, as it could be ;)

RIGHT. No problem with that. Pragmatic issues. Organic solutions. 

But my wonder is this ...

Q: Is it possible to logically depict the filter Operators inter-sequencing?
 
In other words, ONE framework to comprehend their relations?

Best wishes
TT


TonyM

unread,
Dec 20, 2019, 8:05:13 PM12/20/19
to TiddlyWiki
Any such documentation can document the rules and then the exceptions.

It requires collaboration and/or a subject mater expert.

Regards
Tony

Mark S.

unread,
Dec 20, 2019, 8:40:36 PM12/20/19
to TiddlyWiki
The list operator is a constructor, or generator, It ignores its input. So the first filter returns the result of list[population], and the second filter returns the result of list[sample].

The last + operator wins, as it were.

Mark S.

unread,
Dec 20, 2019, 9:33:53 PM12/20/19
to TiddlyWiki
And here's a possible "and" structure that works (I think), but does require you to refer to the list fields with !! notation:

<$list filter="[list[population]] [list[sample]]-[list[population]remove{sample!!list}] -[list[sample]remove{population!!list}]"/>

Mohammad

unread,
Dec 20, 2019, 10:26:51 PM12/20/19
to TiddlyWiki
Hi Mark,
 Many thanks for your reply!
The tiddlywiki.com documentation is quite in this regards! Ones cannot find how list works!
It took me hours to debug the script and find the source of bug in this case!

I do not know if there is any plan to improve TW docs or not.

--Mohammad
Reply all
Reply to author
Forward
0 new messages