Drop

Drop[list,n]
gives list with its first n elements dropped.

Drop[list,-n]
gives list with its last n elements dropped.

Drop[list,{n}]
gives list with its n^(th) element dropped.

Drop[list,{m,n}]
gives list with elements m through n dropped.

Drop[list,{m,n,s}]
gives list with elements m through n in steps of s dropped.

Drop[list,seq1,seq2,]
gives a nested list in which elements specified by have been dropped at level i in list.

DetailsDetails

  • Drop uses the standard sequence specification:
  • Allall elements
    Noneno elements
    nelements 1 through n
    -nlast n elements
    {n}element n only
    {m,n}elements m through n inclusive
    {m,n,s}elements m through n in steps of s
  • Drop can be used on an object with any head, not necessarily List.
  • For a matrix, Drop[list,seq1,seq2] effectively drops all elements except those in a submatrix of list.
  • Drop works on SparseArray objects.
  • Applying Drop to an Association object yields an Association with elements from the specified positions dropped.

ExamplesExamplesopen allclose all

Basic Examples  (6)Basic Examples  (6)

Drop the first 2 elements from a list:

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

Drop the last 3 elements:

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

Drop elements 2 through 4:

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

Drop the second element from an Association:

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

Drop all but the first element from an Association:

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

Drop every other element from 2 to 6 from an Association:

In[1]:=
Click for copyable input
Out[1]=
Introduced in 1988
(1.0)
| Updated in 2014
(10.0)