Subject: Re: [xsl] Get the duplicates in a list From: "Philip Fearon pgfearo@xxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Mon, 13 Jan 2025 16:36:15 -0000 |
Another XPath 3.1 solution - uses fold-left and is not exactly compact: (fold-left($values, [map {}, []], function($acc as array(*), $n as xs:string) { let $map := $acc(1), $result := $acc(2), $isDupe := ($map($n)) return if (empty($isDupe)) then [ map:put($map, $n, false()), $result] else if ($isDupe) then $acc else array { map:put($map, $n, true()), array:append($result, $n)} }))(2) On Fri, Jan 3, 2025 at 10:52b/AM Roger L Costello costello@xxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote: > > Hi Folks, > > $fieldnames is a list of strings, e.g., > > ('TYPE', 'USAGE_CD', 'DIR', 'WGS_LAT', 'TYPE', 'WGS_LONG', 'TURN_DIR', 'DIR', 'TYPE') > > I want a list of the duplicates in $fieldnames: > > ('TYPE', 'DIR') <-- I don't want any duplicates in this list > > Is there a simple XPath expression to obtain the list of duplicates in $fieldnames? > > /Roger
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Get the duplicates in a l, John Lumley john@xxx | Thread | [xsl] Upcoming virtual courses from, Liam R. E. Quin liam |
[xsl] Announcing Balisage 2025 - Ma, B Tommie Usdin btusd | Date | [xsl] I love programs that output p, Roger L Costello cos |
Month |