This is what I get (Mathematica 8):
In[1]: list = {{1, 2}, {3, 1}, {2, 1}, {2, 1}, {1, 1}};
DeleteDuplicates[list]
Out[1]: {{1, 2}, {3, 1}, {2, 1}, {1, 1}}
Question
For instance say,
list = {{1, 2}, {3, 1}, {2, 1}, {2, 1}, {1, 1}}
I would like it to instead print
{{1, 2}, {3, 1}, {2, 1},{ {1, 1}}
I have tried DeleteDuplicates[list]
and that worked to no avail. Any ideas? A loop
and comparing each element would work but would take to much memory as the number of sublists
I have are based on (high) factorial.
Solution
This is what I get (Mathematica 8):
In[1]: list = {{1, 2}, {3, 1}, {2, 1}, {2, 1}, {1, 1}};
DeleteDuplicates[list]
Out[1]: {{1, 2}, {3, 1}, {2, 1}, {1, 1}}
OTHER TIPS
Another command to consider is Union
. When it acts on a single list, it will delete duplicates and sort the outcome.
In[1]:= Union[{{1, 2}, {3, 1}, {2, 1}, {2, 1}, {1, 1}}]
Out[1]= {{1, 1}, {1, 2}, {2, 1}, {3, 1}}