This question is somewhat related to How to efficiently find positions of duplicates?How to efficiently find positions of duplicates? , although I'm interested in something a little bit simpler since I'm not really interested in a list of all the positions of duplicates in a list. I just want to delete duplicates of a given list based on the duplicates of another list.
As a simple example, let's say I have one list
myList = {1,3,1,2}; I perform some operations on this list, which yields a different list, but preserves the length
myNewList = {7,2,2,2}; After deleting duplicates, this list now becomes
myNewListReduced = {7,2}; Now, I would like to remove elements from my original list wherever the duplicates occurred in the new list. I do not necessarily care which of the positions are removed. In myNewList, the duplicates occurred at positions 2,3 and 4. I would like to delete elements in my original list corresponding to that definition of duplicates, so that the following are all acceptable:
myListDuplicatesDeleted = {1,3}; myListDuplicatesDeleted = {1,1}; myListDuplicatesDeleted = {1,2}; That is, 3,1 and 2 from myList are all considered duplicates.
Thank you very much.