Difference
Difference[list1, list2]
Difference[list1, list2] returns a copy of list1 with the elements of list2 removed. The order of the remaining elements in the new list will be the same as in list1.
Note
Each element in list2 is counted and removed only once, working left to right. Therefore, if list1 contains several instances of element1 and list2 contains only a single instance, only the first instance of element1 will be removed.
| Example | in | out |
|---|---|---|
The difference of {a,b,g,a} and {a,b,c,d,e,a}. |
Difference[ {a,b,g,a}, {a,b,c,d,e,a} ] |
{g} |
The difference of {a,b,g,a} and {g,a}. |
Difference[{a,b,g,a}, {g,a}] |
{b,a} |
The difference of x and y, where x is defined as {1,2,a,b} and y is defined as {1, a} in the script. |
Difference[x,y] |
{2,b} |