Depth
Depth(expr)gets the depth of
expr.
Depth(expr, Heads->True)gets the depth of
exprwith head expressions included.
The depth of an expression is defined as one plus the maximum number of Part indices required to reach any part of expr, except for heads.
Examples
>> Depth(x)1
>> Depth(x + y)2
>> Depth({{{{x}}}})5Complex numbers are atomic, and hence have depth 1:
>> Depth(1 + 2*I)1Generally Depth ignores heads.
>> Depth(f(a, b)[c])2But if you include the option Heads->True, the heads depth is included.
Depth(f(a, b)[c], Heads->True)3Implementation status
- ✅ - full supported