Skip to main content
Tweeted twitter.com/#!/StackMma/status/402783976752181248
deleted 9 characters in body
Source Link
RunnyKine
  • 33.3k
  • 3
  • 110
  • 176

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:

list 1list1 = {2, 5, 10, 11, 12, 17, 18};
list 2list2 = {5, 8, 11, 16, 19, 21};
list 3list3 = {5, 8, 9, 11, 16, 19, 21, 23};

I would like to output:

list 1list1 = {2, 5, 10, 11, 12, 17, 18}
list 2list2 = {8, 16, 19, 21}
list 3list3 = {9, 23}

where list 1list1 keeps all its original elements, list 2list2 keeps only elements belonging to list 2list2 and not list 1list1, and list 3list3 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.

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:

list 1 = {2, 5, 10, 11, 12, 17, 18};
list 2 = {5, 8, 11, 16, 19, 21};
list 3 = {5, 8, 9, 11, 16, 19, 21, 23};

I would like to output:

list 1 = {2, 5, 10, 11, 12, 17, 18}
list 2 = {8, 16, 19, 21}
list 3 = {9, 23}

where list 1 keeps all its original elements, list 2 keeps only elements belonging to list 2 and not list 1, and list 3 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.

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.

Source Link
martin
  • 8.9k
  • 4
  • 27
  • 71

Delete duplicates from hierarchy of lists

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:

list 1 = {2, 5, 10, 11, 12, 17, 18};
list 2 = {5, 8, 11, 16, 19, 21};
list 3 = {5, 8, 9, 11, 16, 19, 21, 23};

I would like to output:

list 1 = {2, 5, 10, 11, 12, 17, 18}
list 2 = {8, 16, 19, 21}
list 3 = {9, 23}

where list 1 keeps all its original elements, list 2 keeps only elements belonging to list 2 and not list 1, and list 3 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.