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.

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.

ExamplesExamplesopen allclose all

Basic Examples (2)Basic Examples (2)

Test whether a list is free of :

Click for copyable input

FreeQ normally tests all levels in an expression:

Click for copyable input
New in 1
New to Mathematica? Find your learning path »
Have a question? Ask support »