ArrayDepth[expr]
gives the depth to whichexpr
is a full array, with all the parts at a particular level being lists of the same length, or is aSparseArray
object.
OK, so ArrayDepth
of a symbol (i.e. a scalar quantity) gives 0:
In[1]:= ArrayDepth[f]
Out[1]:= 0
But:
In[2]:= ArrayDepth[f[x]]
Out[2]:= 1
Why? f[x]
is still not a List!
When I have a List
of vector components, then it makes no difference if these components are functions or just symbols:
In[3]:= ArrayDepth[{f, g, h}]
Out[3]:= 1
In[4]:= ArrayDepth[{f[x], g[x], h[x]}]
Out[4]:= 1
Is there a function in Mathematica that returns the true "nestedness" of the List
, i.e. the number of indices needed to access elements of the List
, without paying attention to square brackets? (I assume regular nested lists, where all levels have the same length). So it should give 0 for any non-List
, 1 for vectors, 2 for regular matrices, etc.
ArrayDepth[]
, I take it. Anyway... "I assume regular nested lists, where all levels have the same length" - so, something that passesArrayQ[]
. $\endgroup$ArrayQ
Unclear, if you ask me. So a "regular" matrix which has some of its elements as lists has anArrayDepth
of 0? $\endgroup$ArrayQ[]
: "ArrayQ[expr]
givesTrue
ifexpr
is a full array or aSparseArray
object, and givesFalse
otherwise." $\endgroup$