Hi,
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?
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
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>
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>
Hello Giuseppe, Would this do what you want: let $reference := (1,3,2,3) for $a in (1,2,3,5,3) where $a = $reference return <c>{$a}</c> Depending on how your $reference looks like, e.g. if it has many duplicates, you can compact it by doing let $reference := distinct- values((1,3,2,3))either way the returned sequence will be identical. Best regards,Kristian Kankainen Ühel kenal päeval, N, 26.11.2020 kell 02:28, kirjutas Giuseppe G. A. Celano:
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 oftheir positions: for $a in (1,2,3,5,3)for $u in (1,3,2,3)where $a = $ugroup by $o := $areturn<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 firstsequence should pair only with one in the second sentence): is there anXQuery "trick" for that in the FLOWR expression?
I think for $a in (1,2,3,5,3)[. = (1,3,2,3)]group by $o := $areturn<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>
basex-talk@mailman.uni-konstanz.de