Delete

Delete[expr,n]
deletes the element at position n in expr. If n is negative, the position is counted from the end.

Delete[expr,{i,j,}]
deletes the part at position .

Delete[expr,{{i1,j1,},{i2,j2,},}]
deletes parts at several positions.

Delete[pos]
represents an operator form of Delete that can be applied to an expression.

DetailsDetails

  • Deleting the head of a particular element in an expression is equivalent to applying FlattenAt to the expression at that point. »
  • Deleting the head of a whole expression makes the head be Sequence. »
  • Deleting a whole expression gives the result Sequence[].
  • Delete works on SparseArray objects.
  • Applying Delete to an Association object yields an Association in which elements from the specified positions have been deleted.
  • Delete[pos][expr] is equivalent to Delete[expr,pos].

ExamplesExamplesopen allclose all

Basic Examples  (5)Basic Examples  (5)

Delete the element at position 3:

In[1]:=
Click for copyable input
Out[1]=

Delete at position 2 from the end:

In[1]:=
Click for copyable input
Out[1]=

Delete at positions 1 and 3:

In[1]:=
Click for copyable input
Out[1]=

Delete in a 2D array:

In[1]:=
Click for copyable input
Out[1]=

Delete from an Association:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
Introduced in 1991
(2.0)
| Updated in 2014
(10.0)