[xquery-talk] Purely recursive deduplication of sequence?

Andreas Mixich mixich.andreas at gmail.com
Sat Aug 1 08:58:38 PDT 2020


Am 01.08.2020 um 14:57 schrieb Christian Grün:

Thank you so much for all three examples!

Of course, in the end, I am going to take the one, which has the
best performance. Do you expect it to be the `FLOWR` based or
the `fold-left#3` based, you demonstrated in the follow-up?

Still, I am glad to see this one, since it surprises me, as to how
short this can be! My own ponderings started to get out of hand by
adding more and more code - to no avail. That was when I gave up
and just asked.

> declare function local:distinct-items($items as item()*) as item()* {
>   if (empty($items)) then () else (
>     head($items),
>     local:distinct-items(tail($items)[not(deep-equal(., head($items)))])
>   )
> };


-- 
Goody Bye, Minden jót, Mit freundlichen Grüßen,
Andreas Mixich



More information about the talk mailing list