Function Repository Resource:

# DeleteFrom

Delete an element from the value of a symbol and reset the symbol to the result

Contributed by: Ian Ford
 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.

## Details and Options

ResourceFunction["DeleteFrom"][x,pos] is equivalent to x=Delete[x,pos].
ResourceFunction["DeleteFrom"] has attribute HoldFirst.
Deleting the head of a particular element from x sets it equal to the result of applying FlattenAt to the value of x at that point.
Deleting position {} from x sets the value to Sequence[].
ResourceFunction["DeleteFrom"] works on SparseArray objects.
ResourceFunction["DeleteFrom"] works on associations, removing elements with the specified keys and returning them.

## Examples

### Basic Examples (3)

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]=

### Scope (1)

DeleteFrom works on sparse arrays:

 In[11]:=
 Out[11]=
 In[12]:=
 Out[12]=

### Properties and Relations (3)

 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]=

## Requirements

Wolfram Language 11.3 (March 2018) or above

## Version History

• 1.0.0 – 17 December 2018