Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'DeleteDuplicates isn't deleting anything' topicStudent Support Forum > General > Archives > "DeleteDuplicates isn't deleting anything"

Next Comment >Help | Reply To Topic
Author Comment/Response
Ben Smith
10/31/11 09:56am

So I have a list that is, well, huge. The data looks like this:

{{"Australia", "Austria"}, {"Australia", "Belgium"}, {"Australia",
"Canada"} ......


In the context of my problem, Austria to Belgium is the same as Belgium to Austria. So, I want to delete duplicates based on that criteria.


DeleteDuplicates[
MAINLIST, (ToString[Extract[#1, {1}]] ==
ToString[Extract[#2, {1}]] &&
ToString[Extract[#1, {2}]] ==
ToString[Extract[#2, {2}]]) || (ToString[Extract[#1, {2}]] ==
ToString[Extract[#2, {1}]] &&
ToString[Extract[#1, {1}]] == ToString[Extract[#2, {2}]]) &];

However when I do a length on MAINLIST before and after the deletion process, there is exactly the same number of elements.

Does anyone know what I'm doing wrong?

URL: ,

Subject (listing for 'DeleteDuplicates isn't deleting anything')
Author Date Posted
DeleteDuplicates isn't deleting anything Ben Smith 10/31/11 09:56am
Re: DeleteDuplicates isn't deleting anything qm2008q 11/24/11 10:44pm
Next Comment >Help | Reply To Topic