Skip to content

Instantly share code, notes, and snippets.

@emchateau
Last active June 12, 2020 21:46
Show Gist options
  • Save emchateau/938ea6d51acd4686b6f7c39560387c1d to your computer and use it in GitHub Desktop.
Save emchateau/938ea6d51acd4686b6f7c39560387c1d to your computer and use it in GitHub Desktop.
pairs combinations in a sequence with XQuery
xquery version "3.1" ;
(:~
: Pairs combinations in a sequence
: Unique pairs in a sequence (where order is irrelevant)
:)
let $seq := ("a", "b", "b", "d")
for $i at $pos in $seq
for $j in fn:subsequence($seq, $pos+1, fn:count($seq))
return <result>{$i, $j}</result>
@emchateau
Copy link
Author

 .   1,2  1,3  1,4
 .    .   2,3  2,4
 .    .    .   3,4
 .    .    .    .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment