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 seqi have been dropped at level i in list.

Details

  • Drop uses the standard sequence specification:
  • Allall elements
    Noneno elements
    nelements 1 through n
    UpTo[n]elements 1 up to at most n, as available
    -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.

Examples

open allclose all

Basic Examples  (6)

Drop the first 2 elements from a list:

Drop the last 3 elements:

Drop elements 2 through 4:

Drop the second element from an Association:

Drop all but the first element from an Association:

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

Scope  (8)

Drop elements from the third to the third-to-last:

Drop every other element:

Drop the first row of a matrix:

Drop the first row, and the first two columns:

Drop none of the rows, but the first two columns:

Drop rows 2 through 4 and columns 3 through 5:

Drop every other row and every third column:

Drop the first 4 elements if possible, or as many as are available:

Generalizations & Extensions  (2)

Drop works with any head, not just List:

Drop works with SparseArray objects:

Applications  (1)

Pick out a subimage:

Properties & Relations  (3)

Drop and Take are complementary:

Rest is a special case of Drop:

Most is a special case of Drop:

Possible Issues  (1)

Drop always gives a list, even if only one element remains:

Wolfram Research (1988), Drop, Wolfram Language function, https://reference.wolfram.com/language/ref/Drop.html (updated 2015).

Text

Wolfram Research (1988), Drop, Wolfram Language function, https://reference.wolfram.com/language/ref/Drop.html (updated 2015).

CMS

Wolfram Language. 1988. "Drop." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015. https://reference.wolfram.com/language/ref/Drop.html.

APA

Wolfram Language. (1988). Drop. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Drop.html

BibTeX

@misc{reference.wolfram_2023_drop, author="Wolfram Research", title="{Drop}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/Drop.html}", note=[Accessed: 19-March-2024 ]}

BibLaTeX

@online{reference.wolfram_2023_drop, organization={Wolfram Research}, title={Drop}, year={2015}, url={https://reference.wolfram.com/language/ref/Drop.html}, note=[Accessed: 19-March-2024 ]}