FreeQ

FreeQ[expr,form]
yields True if no subexpression in expr matches form, and yields False otherwise.

FreeQ[expr,form,levelspec]
tests only those parts of expr on levels specified by levelspec.

FreeQ[form]
represents an operator form of FreeQ that can be applied to an expression.

Details and OptionsDetails and Options

  • form can be a pattern.
  • FreeQ uses standard level specifications:
  • nlevels through n
    Infinitylevels through Infinity
    {n}level n only
    {n1,n2}levels through
  • The default value for levelspec in FreeQ is {0, Infinity}.
  • 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 default option setting Heads->True, FreeQ looks at heads of expressions, and their parts.
  • FreeQ works on associations, testing values but not keys.
  • FreeQ[form][expr] is equivalent to FreeQ[expr,form].
Introduced in 1988
(1.0)
| Updated in 2014
(10.0)