Should tobibeer's split:list remove duplicates?

121 views
Skip to first unread message

David Nebauer

unread,
Apr 23, 2019, 7:32:28 AM4/23/19
to TiddlyWiki
This tiddlyscript:

<$set name="HasDuplicates" value="one two two three [[twenty one]] [[twenty one]] [[forty six]]">

<$list filter="[split:list<HasDuplicates>]">

</$list>

xXx

<$list filter="[enlist<HasDuplicates>]">

</$list>

</$set>

results in:


There are duplicate items in the list, and in this example split:list removes them just as enlist does. It is my understanding that tobibeer's split filter is not supposed to remove duplicates unless the 'unique' suffix is used. Does anyone know if there any way to use tobibeer's split filter to obtain a list that keeps duplicate items? (Or any other method?)

TW5/nodejs 5.1.19
tobibeers/split plugin 0.8.0

Note: I am aware that TW 5.1.20 will have a split operator that retains duplicates, but I'm hoping for a solution in days rather than [insert TW 5.1.20 release schedule here].

Regards,
David

Jed Carty

unread,
Apr 23, 2019, 7:41:46 AM4/23/19
to TiddlyWiki
Filters currently enforce uniqueness in almost all cases. So I am not sure if this has a solution other than updating the filters.js tiddler.

I think in some cases if the filter operator doesn't explicitly remove duplicates and is the last in a filter run it may return duplicates, but I don't remember the specific circumstances where I got that to work so I may be misremembering.

TonyM

unread,
Apr 23, 2019, 5:19:28 PM4/23/19
to TiddlyWiki
David,

Until this is resolved with the new maths operators you may b able to find an alternate way to achieve what you want, in your example you are setting HasDuplicates with a string of titles. 

Perhaps explain not so much how you are doing this but what and why you are doing this?

There should be a code work around.

Regards
Tony

David Nebauer

unread,
Apr 23, 2019, 7:28:21 PM4/23/19
to tiddl...@googlegroups.com
I'm processing rows from a dictionary tiddler into raw html table rows, and each tiddler row needs to be split into individual elements. There may be duplicate elements in a single row. An enlist analogue that preserves duplicates would be ideal for the task.

Regards,
David

--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/o7cwG5kYl4E/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/2fa8b904-a989-4820-be4e-8fcb058163cf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

David Nebauer

unread,
Apr 24, 2019, 7:38:50 AM4/24/19
to TiddlyWiki
Hmm, in its current form the 5.1.20 'split' operator can be used to "listify" a string and preserve duplicates... but it does not respect the TW convention of enclosing values with double square brackets when they contain spaces. As an example, in 5.1.20-prerelease:

<$set name="HasDuplicates" value="one two two three [[twenty one]] [[twenty one]] [[forty six]]">

<$list filter="[<HasDuplicates>split[ ]]">

</$list>

results in:
The duplicate entries are, indeed, preserved. Unfortunately, the double square brackets are treated as regular characters.

It would be necessary to use tabs, or more exotic characters, as a value delimiter when values may contain spaces. This means the user has to remember different data-encoding conventions for different operations, and in the worst case the same data may have to be stored in multiple formats. Also, it's human-unfriendly to work with tabs and spaces in the same strings when they have different semantic meanings :-)

My quixotic quest for a drop in enlist-but-with-duplicate-preservation replacement continues...

I'll start a fresh topic about that broader question.

Regards,
David.
Message has been deleted

Ste Wilson

unread,
Apr 24, 2019, 12:42:43 PM4/24/19
to TiddlyWiki
Off topic but what's happened to tobibeer? He used to be a regular wizard here..

TonyM

unread,
Apr 24, 2019, 9:52:17 PM4/24/19
to TiddlyWiki
David

Since here you are processing a list of elements stored in a data tiddler by index, do you control the delimiters to be used? Perhaps you choose appropriate delimiter(s) and split based on that eg commas or even multiple characters.

Regards
Tony

David Nebauer

unread,
Apr 26, 2019, 2:01:23 AM4/26/19
to TiddlyWiki
For anyone in the future who stumbles across this topic, I eventually found a solution to my need for an enlist replacement that allows duplicates. See this topic for details.

Regards,
David.
Reply all
Reply to author
Forward
0 new messages