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 {i,j,}.

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.

Details

  • 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.
  • Delete works on associations, deleting elements with the specified keys.
  • Delete[pos][expr] is equivalent to Delete[expr,pos].

Examples

open allclose all

Basic Examples  (5)

Delete the element at position 3:

Delete at position 2 from the end:

Delete at positions 1 and 3:

Delete in a 2D array:

Delete from an Association:

Generalizations & Extensions  (3)

Delete in an expression with any head:

Delete at any position in any expression:

Delete a head to splice in its arguments:

Properties & Relations  (2)

Deleting the head of a whole expression gives a Sequence object:

Deleting at an empty list of positions does not change the expression:

Deleting at position {} eliminates the whole expression:

Wolfram Research (1991), Delete, Wolfram Language function, https://reference.wolfram.com/language/ref/Delete.html (updated 2014).

Text

Wolfram Research (1991), Delete, Wolfram Language function, https://reference.wolfram.com/language/ref/Delete.html (updated 2014).

CMS

Wolfram Language. 1991. "Delete." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2014. https://reference.wolfram.com/language/ref/Delete.html.

APA

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

BibTeX

@misc{reference.wolfram_2024_delete, author="Wolfram Research", title="{Delete}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/Delete.html}", note=[Accessed: 22-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_delete, organization={Wolfram Research}, title={Delete}, year={2014}, url={https://reference.wolfram.com/language/ref/Delete.html}, note=[Accessed: 22-November-2024 ]}