This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
 BUILT-IN MATHEMATICA SYMBOL Tutorials »| See Also »| More About »

# Cases

 Casesgives a list of the that match the pattern. Casesgives a list of the values of rhs corresponding to the that match the pattern. Casesgives a list of all parts of expr on levels specified by levelspec that match the pattern. Casesgives the values of rhs that match the pattern. Casesgives the first n parts in expr that match the pattern.
• The first argument to Cases need not have head List.
• Cases evaluates rhs only when the pattern is found.
• Cases uses standard level specifications:
 n levels through n Infinity levels through Infinity {n} level n only {n1,n2} levels through
• The default value for levelspec in Cases is .
• 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 consists of numbers, symbols and other objects that do not have subparts.
• Level corresponds to the whole expression.
• With the option setting Heads->True, Cases looks at heads of expressions, and their parts.
• Cases traverses the parts of expr in a depth-first order, with leaves visited before roots.
Find cases that explicitly match integers:
Find cases that do not match integers:
Return the from inside each matched:
Find cases that explicitly match integers:
 Out[1]=
Find cases that do not match integers:
 Out[2]=

Return the from inside each matched:
 Out[1]=
 Scope   (4)
Find all cases of lists of two elements:
Find the sum of every pair of elements:
Pick out elements that are not :
Pick out cases of integers down to level 2:
Use to evaluate only after explicit elements have been found:
New in 1 | Last modified in 5