AllowedHeads
is an option that specifies the heads of subexpressions into which a function may descend.
Details
- Different functions use different default settings for AllowedHeads.
- Settings for the AllowedHeads option include:
-
Automatic default settings Inherited allow only Head[expr] All allow any normal expression head h allow only head h {h1,…} allow any of h1,… h1h2… treat the hi as interchangeable Full treat all normal expression heads as interchangeable - For AllowedHeads, a normal expression head is the head of an expression that is not AtomQ, Association or the head of a special array object such as SparseArray, NumericArray and QuantityArray.
- For functions such as Dimensions, the setting AllowedHeads->{h1,h2,…} requires that all elements at a given level have the same head. AllowedHeads->{…,g1g2…,…} allows any of the gi as heads at a given level.
Examples
open allclose allBasic Examples (4)
Scope (3)
By default, Total only sums inside list representations and associations:
Sum inside several specific heads:
Allow any head at each level of the array:
An array has a consistent head at each level:
Completely ignore heads, looking only at the tree structure of the expression:
Treat the heads g and h as the same head:
Without this stronger equivalence, the expression is considered one-dimensional:
Applications (1)
Properties & Relations (2)
Once a head is excluded, no nested expressions are tested against the value of AllowedHeads:
If both f and List are allowed, then the inner list is tested and summed:
The meaning of AllowedHeads->Automatic may vary from function to function:
Text
Wolfram Research (2019), AllowedHeads, Wolfram Language function, https://reference.wolfram.com/language/ref/AllowedHeads.html (updated 2020).
CMS
Wolfram Language. 2019. "AllowedHeads." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2020. https://reference.wolfram.com/language/ref/AllowedHeads.html.
APA
Wolfram Language. (2019). AllowedHeads. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/AllowedHeads.html