Skip to content

Drop

Status: Stable

documented, exercised by the test suite and/or worked examples, with no known limitations recorded.

Description

Drop[list, n]
    gives list with its first n elements dropped.
Drop[list, -n]
    drops the last n elements.
Drop[list, {m, n}]
    drops elements m through n.
Drop[list, {m, n, s}]
    drops elements m through n in steps of s.
Drop[list, {m}]
    drops the single element at position m.
Drop[list, spec1, spec2, ...]
    drops elements at successive levels.

Negative indices count from the end; UpTo[n], All, and None are also accepted.
Indices are 1-based; out-of-range requests leave the expression unevaluated.

Examples

No verified examples yet for this function.

Implementation notes

Attributes: NHoldRest, Protected.

Implementation status

Stable — documented, exercised by the test suite and/or worked examples, with no known limitations recorded.

References

Notes & additional examples

Worked examples

In[1]:= Drop[{a, b, c, d, e}, 2]
Out[1]= {c, d, e}
In[1]:= Drop[{a, b, c, d, e}, -2]
Out[1]= {a, b, c}
In[1]:= Drop[{a, b, c, d, e}, {2, 4}]
Out[1]= {a, e}
In[1]:= Drop[{a, b, c, d, e, f, g}, {2, 7, 2}]
Out[1]= {a, c, e, g}
In[1]:= Drop[{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}, {2}, {2}]
Out[1]= {{1, 3}, {7, 9}}

Notes

Drop is the complement of Take. A plain count drops from the front (Drop[list, n]) or, with a negative count, from the back. The {m, n} form drops a contiguous block, {m, n, s} drops a strided slice, and {m} drops a single element. Multiple level specifications drop along successive list dimensions, so the {2}, {2} example deletes the second row and the second column of a matrix in one call. Indices are 1-based and negative indices count from the end; out-of-range requests leave the expression unevaluated.