Unfortunately this does not work because, if the second sequence has only one 3 (and the first has two 3), I will still get two 3, while I should get only one.
Or more FLOWR like for $a in (1,2,3,5,3) where $a . = (1,3,2) group by $o := $a return <c>{$a}</c>
On 25. Nov 2020, at 09:11, Martin Honnen martin.honnen@gmx.de wrote:
Am 25.11.2020 um 08:39 schrieb Martin Honnen:
Am 25.11.2020 um 06:37 schrieb Giuseppe G. A. Celano:
I have to compare two sequences and find common items, irrespective of their positions:
for $a in (1,2,3,5,3) for $u in (1,3,2,3) where $a = $u group by $o := $a return <c>{$a}</c>
This returns <c>1</c> <c>2</c> <c>3 3 3 3</c>
I would like 3 to be repeated only twice (i.e., each item in the first sequence should pair only with one in the second sentence): is there an XQuery "trick" for that in the FLOWR expression?
I think
for $a in (1,2,3,5,3)[. = (1,3,2,3)] group by $o := $a return <c>{$a}</c>
would do that
Or more FLOWR like for $a in (1,2,3,5,3) where $a . = (1,3,2,3) group by $o := $a return <c>{$a}</c>