Skip to content

Instantly share code, notes, and snippets.

@dizzzz
Last active March 18, 2024 17:33
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dizzzz/a77f04f2fbf5e3422d4e05384ae8d9ef to your computer and use it in GitHub Desktop.
Save dizzzz/a77f04f2fbf5e3422d4e05384ae8d9ef to your computer and use it in GitHub Desktop.
xquery find duplicates in sequence
(: wolfgang :)
for $i in (1, 5, 2, 4, 5)
group by $j := $i
return
    $j || ": " || count($i)
(: adam :)
let $seq := (1, 5, 2, 4, 5)
return
    distinct-values(
        for $s in $seq
        where count($seq[. eq $s]) gt 1
        return $s
    )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment