Depth
Depth[expr]
gives the maximum number of indices needed to specify any part of expr, plus 1.
Examples
open allclose allBasic Examples (3)
Scope (10)
Depths of General Expressions (5)
Depths of Special Expressions (5)
Keys are ignored when computing the depth of an association:
The depth of values is considered when computing the depth of an association:
Depth of a nested association:
Depth treats SparseArray and structured array objects just like the corresponding ordinary lists:
Applications (2)
Find how deeply nested results from integrals are:
Find the depths of combinator expressions [more info]:
Properties & Relations (5)
Depth generally gives the length of the maximum index, plus 1:
Depth considers the deepest part of an expression:
ArrayDepth only considers the levels to which the expression is completely rectangular:
For completely rectangular expressions, Depth gives a result one greater than ArrayDepth:
Depth[expr] is the smallest positive level k for which Level[expr,{k}] returns an empty list:
If length-0 functions or compound heads are present, both Depth and Level must use HeadsTrue:
Successive elements from NestList have larger depths:
Possible Issues (3)
Depth returns a depth one greater than that returned by ArrayDepth:
Depth counts an association as a single level:
It counts the corresponding list of rules as two levels:
The relationship between Depth and Position can break down when compound heads are present:
Text
Wolfram Research (1988), Depth, Wolfram Language function, https://reference.wolfram.com/language/ref/Depth.html (updated 2018).
CMS
Wolfram Language. 1988. "Depth." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2018. https://reference.wolfram.com/language/ref/Depth.html.
APA
Wolfram Language. (1988). Depth. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Depth.html