Function difference() calculates the elements that exist in the 1st list but not in the 2nd list and returns them as a new list, namely, returns the difference of these two lists (repeated elements are allowed in the difference).
Arguments:
Returns:
Exalmple: 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(difference(a, b)))
Result| toString(a) | toString(b) | toString(difference(a, b)) | |-------------|-------------|----------------------------| | [1,2,2] | [2,4,7] | [1,2] | | [2,4,5] | [4,5,7] | [2] |
Exalmple: Multiply and calculate
UQLuncollect [[1,2,2],[2,4,5]] as a uncollect [[2,4,7],[4,5,7]] as b with difference(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] | [1,2] | | [1,2,2] | [4,5,7] | [1,2,2] | | [2,4,5] | [2,4,7] | [5] | | [2,4,5] | [4,5,7] | [2] |
Sample graph: (to be used for the following examples)

Example: Find the students that select French but not 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 difference(l1, l2)
Result[ {"id":"","uuid":"1","schema":"student","values":{}} ]