Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Delete an element from the value of a symbol and reset the symbol to the result
ResourceFunction["DeleteFrom"][x,n] deletes the element at position n in the value of x, and resets x to the result. If n is negative, the position is counted from the end. | |
ResourceFunction["DeleteFrom"][x,{i,j,…}] deletes the part at position {i,j,…} from x. | |
ResourceFunction["DeleteFrom"][x,{{i1,j1,…},{i2,j2,…}}] deletes parts at several positions. |
Assign x to a list:
In[1]:= | ![]() |
Out[1]= | ![]() |
Delete the element at position 3 from the list:
In[2]:= | ![]() |
Out[2]= | ![]() |
The value assigned to x has changed:
In[3]:= | ![]() |
Out[3]= | ![]() |
Delete at position 2 from the end:
In[4]:= | ![]() |
Out[4]= | ![]() |
Delete at positions 1 and 3:
In[5]:= | ![]() |
Out[5]= | ![]() |
Delete from a 2D array:
In[6]:= | ![]() |
Out[6]= | ![]() |
In[7]:= | ![]() |
Out[7]= | ![]() |
Delete from an Association:
In[8]:= | ![]() |
Out[8]= | ![]() |
In[9]:= | ![]() |
Out[9]= | ![]() |
In[10]:= | ![]() |
Out[10]= | ![]() |
DeleteFrom works on sparse arrays:
In[11]:= | ![]() |
Out[11]= | ![]() |
In[12]:= | ![]() |
Out[12]= | ![]() |
Deleting the head makes the head be Sequence:
In[13]:= | ![]() |
Out[13]= | ![]() |
In[14]:= | ![]() |
Out[14]= | ![]() |
Deleting at an empty list of positions does not change the value:
In[15]:= | ![]() |
Out[15]= | ![]() |
In[16]:= | ![]() |
Out[16]= | ![]() |
Deleting at position {} deletes the whole expression:
In[17]:= | ![]() |
Out[17]= | ![]() |
In[18]:= | ![]() |
Out[18]= | ![]() |
Wolfram Language 11.3 (March 2018) or above
This work is licensed under a Creative Commons Attribution 4.0 International License