From 753b289ba95d699341b588c6615fec0882b118f7 Mon Sep 17 00:00:00 2001 From: springerspandrel <66639553+springerspandrel@users.noreply.github.com> Date: Tue, 9 Jul 2024 11:34:18 -0400 Subject: [PATCH] Clarify opposite handling of de-duplication order for unique Operator vs Dominant Append (#8357) --- editions/tw5.com/tiddlers/concepts/Dominant Append.tid | 4 +++- editions/tw5.com/tiddlers/filters/unique.tid | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/editions/tw5.com/tiddlers/concepts/Dominant Append.tid b/editions/tw5.com/tiddlers/concepts/Dominant Append.tid index 59e79d6c79..c473936bb9 100644 --- a/editions/tw5.com/tiddlers/concepts/Dominant Append.tid +++ b/editions/tw5.com/tiddlers/concepts/Dominant Append.tid @@ -1,5 +1,5 @@ created: 20150123220223000 -modified: 20190610165255223 +modified: 20240709151004998 tags: Filters title: Dominant Append type: text/vnd.tiddlywiki @@ -13,3 +13,5 @@ For example, if a selection contains `Andrew Becky Clara Daniel` and `Andrew Bar This behaviour can cause unexpected results when working with [[Mathematics Operators]]. For example, `1 2 3 +[sum[]]` evaluates to `6`, as expected. But `1 1 1 +[sum[]]` evaluates to `1`. Removing the `+[sum[]]` from each filter reveals the problem: `1 2 3` evaluates to the list `1`, `2`, `3`, while `1 1 1` evaluates to the single item `1` due to de-duplication. In such situations, the `=` prefix can be used to disable the de-duplication. For example, `=1 =1 =1 +[sum[]]` evaluates to `3` as expected. Alternatively, the [[split Operator]] can be used: `[[1,1,1]split[,]sum[]]`. + +<<.tip """To build a list of unique values that retains only the <<.em earliest>> copy of each value (the opposite behavior from <<.link "Dominant Append" "Dominant Append">>), first use the <<.link `:all` "All Filter Run Prefix">> filter run prefix (or its short form `=`) to retain all duplicate values while building your list. Then finish your filter run with the <<.olink unique>> operator" to remove later duplicates.""">> \ No newline at end of file diff --git a/editions/tw5.com/tiddlers/filters/unique.tid b/editions/tw5.com/tiddlers/filters/unique.tid index 672817968e..836c41db8a 100644 --- a/editions/tw5.com/tiddlers/filters/unique.tid +++ b/editions/tw5.com/tiddlers/filters/unique.tid @@ -1,4 +1,6 @@ caption: unique +created: 20240709151018238 +modified: 20240709151336906 op-input: a list of items op-output: a list of unique items op-parameter: ignored @@ -7,4 +9,6 @@ tags: [[Filter Operators]] [[Order Operators]] [[Listops Operators]] title: unique Operator type: text/vnd.tiddlywiki +<<.note """Unlike the default <<.link "Dominant Append" "Dominant Append">> handling of duplication, the effect of <<.op unique>> is to retain only the <<.em earliest>> instance among duplicated values.""">> + <<.operator-examples "unique">>