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 Options

  • form can be a pattern.
  • FreeQ uses standard level specifications:
  • nlevels 1 through n
    Infinitylevels 1 through Infinity
    {n}level n only
    {n1,n2}levels n1 through n2
  • 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 -1 consists of numbers, symbols and other objects that do not have subparts.
  • Level 0 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].
  • Parallelize[FreeQ[expr,form]] computes FreeQ[expr,form] in parallel on all subkernels. »

Examples

open allclose all

Basic Examples  (3)

Test whether a list is free of 0:

FreeQ normally tests all levels in an expression:

Test whether an association does not contain a value:

Scope  (5)

FreeQ works with patterns:

Use Verbatim to test for a literal blank:

Test whether an association contains a specific rule:

Test whether a list of rules contains a specific rule:

Test whether an association contains a specific key:

Applications  (2)

Define a function that factors out "constants":

Test which integrals are free of logarithms:

Properties & Relations  (1)

Compute FreeQ in parallel:

Possible Issues  (2)

For associations, FreeQ tests only values:

KeyValuePattern tests for the entire rule:

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

Text

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

CMS

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

APA

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

BibTeX

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

BibLaTeX

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