Function intersection() calculates the common elements of two lists and returns them as a new list, namely, returns the intersection of these two lists (repeated elements are allowed in the intersection).
Arguments:
Returns:
Example: Direct calculate
UQLuncollect [[1,2,2],[2,4,5]] as a uncollect [[2,4,7],[4,5,7]] as b return table(toString(a), toString(b), toString(intersection(a, b)))
Result| toString(a) | toString(b) | toString(intersection(a, b)) | |-------------|-------------|------------------------------| | [1,2,2] | [2,4,7] | [2] | | [2,4,5] | [4,5,7] | [4,5] |
Example: Multiply and calculate
UQLuncollect [[1,2,2],[2,4,5]] as a uncollect [[2,4,7],[4,5,7]] as b with intersection(a, b) as c return table(toString(a), toString(b), toString(c))
Result| toString(a) | toString(b) | toString(c) | |-------------|-------------|-------------| | [1,2,2] | [2,4,7] | [2] | | [1,2,2] | [4,5,7] | [] | | [2,4,5] | [2,4,7] | [2,4] | | [2,4,5] | [4,5,7] | [4,5] |
Sample graph: (to be used for the following examples)

Example: Find the students that select both French and Math
UQLkhop().src({name == "French"}).depth(1) as n1 with collect(n1) as l1 khop().src({name == "Math"}).depth(1) as n2 with collect(n2) as l2 return intersection(l1, l2)
Result[ {"id":"","uuid":"2","schema":"student","values":{}}, {"id":"","uuid":"3","schema":"student","values":{}} ]