Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Delete adjacent duplicates from a list
ResourceFunction["DeleteAdjacentDuplicates"][list] deletes adjacent duplicate items from list. | |
ResourceFunction["DeleteAdjacentDuplicates"][list,test] applies test to pairs of adjacent elements in list to determine if they should be considered duplicates. |
Delete adjacent duplicated elements:
| In[1]:= |
| Out[1]= |
Delete elements whose values duplicate those just before them in the association:
| In[2]:= |
| Out[2]= |
Delete elements unless they are larger than the preceding ones:
| In[3]:= |
| Out[3]= |
Delete adjacent duplicates from an association without evaluating any of the keys or values:
| In[4]:= |
| Out[4]= |
| In[5]:= |
| Out[5]= |
They will still evaluate if unpacked from the association:
| In[6]:= |
| Out[6]= |
Use Unevaluated to delete adjacent duplicates before they can evaluate:
| In[7]:= |
| Out[7]= |
The first argument can be any nonatomic expression:
| In[8]:= |
| Out[8]= |
This work is licensed under a Creative Commons Attribution 4.0 International License