This is documentation for Mathematica 6, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

DeleteCases

DeleteCases[expr, pattern]
removes all elements of expr which match pattern.
DeleteCases[expr, pattern, levelspec]
removes all parts of expr on levels specified by levelspec which match pattern.
DeleteCases[expr, pattern, levelspec, n]
removes the first n parts of expr which match pattern.
  • With the option Heads->True, you can delete heads with DeleteCases. Deleting the head of a particular element in an expression is equivalent to applying FlattenAt to the expression at that point.
nlevels 1 through n
Infinitylevels 1 through Infinity
{n}level n only
{n1,n2}levels n1 through n2
  • The default value for levelspec in DeleteCases is {1}.
  • A positive level n consists of all parts of expr specified by n indices.
  • A negative level -n consists of all parts of expr with depth n.
  • Level -1 consists of numbers, symbols and other objects that do not have subparts.
  • Level 0 corresponds to the whole expression.
  • DeleteCases traverses the parts of expr in a depth-first order, with leaves visited before roots.
New in 2 | Last modified in 4.1