Question: how to produce a list of unique list items from a filter search?

53 views
Skip to first unread message

Hubert

unread,
Mar 5, 2020, 1:13:27 PM3/5/20
to TiddlyWiki
Hello,

Apologies for awkward phrasing in the title :) Here's what I mean, in code:

TiddlerTest1!!list = banana apple
TiddlerTest2!!list = banana

<$list filter="[all[tiddlers]search:title[TiddlerTest]has[list]]">
<$list filter="[list[!!list]]">

output
: banana apple banana

</$list>
</
$list>

The output I get is: banana apple banana
What I'm trying to get is: banana apple -- so, basically a list of unique list items.

I know that the problem here is that I have a "for loop" within a "for loop" (in Python speak) and no way of eliminating thus produced duplicates.

Could anyone suggest a fix to my lists that would produce a list of unique items?

Thank you in advance.

Regards,
Hubert

Mat

unread,
Mar 5, 2020, 1:39:33 PM3/5/20
to TiddlyWiki
<$list filter="[all[tiddlers]prefix[TiddlerTest]get[list]]">

</$list>

I think this should be enough.

<:-)

Hubert

unread,
Mar 5, 2020, 1:49:17 PM3/5/20
to TiddlyWiki
Mat, thanks simplifying the code.

Unfortunately, the output I get still contains duplicates.

I've tried "each" in the meantime as well, but still no luck.

Many thanks,
Hubert

Mat

unread,
Mar 5, 2020, 2:35:56 PM3/5/20
to TiddlyWiki
Here's a... um... really awkward way that at least seems to work. I really hope this is not the best solution:

<$set name=foo filter="[all[tiddlers]prefix[New]get[list]]">
<$wikify name=bar text={{{ [
<foo>] }}}>
<$list filter=<
<bar>>>

</$list>
</$wikify>
</$set>

@Mark? @Eric? This feels like your hood.

<:-)

Hubert

unread,
Mar 5, 2020, 4:10:41 PM3/5/20
to TiddlyWiki
Thanks Mat!

After experimenting some more with filters / reading the documentation, I was able to come up with a one-line filter expression that works:

<$list filter="[all[tiddlers]prefix[TiddlerTest]has[list]each:list-item[list]]">

</$list>

I guess the missing bit here was each:list-item, somewhat mysterious ;) but -- it works!

Thanks again,
-Hubert 

TonyM

unread,
Mar 5, 2020, 8:37:18 PM3/5/20
to TiddlyWiki
Hubert;

Thanks for sharing back.

I expect the need to use each:list-item is because list fields can include the `[[ ]]` for tiddler titles containing spaces. If this were not so in your example the titles with spaces could get broken into pieces with mismatched "[[" and "]]" floating around.

Regards
Tony
Reply all
Reply to author
Forward
0 new messages