Is it possible for Mathematica to compare a number of lists of different sizes, and delete duplicates in a hierarchical manner?
For example, given the following lists:
list1 = {2, 5, 10, 11, 12, 17, 18};
list2 = {5, 8, 11, 16, 19, 21};
list3 = {5, 8, 9, 11, 16, 19, 21, 23};
I would like to output:
list1 = {2, 5, 10, 11, 12, 17, 18}
list2 = {8, 16, 19, 21}
list3 = {9, 23}
where list1
keeps all its original elements, list2
keeps only elements belonging to list2
and not list1
, and list3
keeps only those elements not contained in lists 1 & 2
.
If this will take an inordinately long time, I am happy with just comparing the list with the previous list and deleting the duplicates from the second list.