I'm looking for a function that gives the depth of nested lists in an expression. I do not want to include contributions from things like f[1]
. Depth does do this. Note Depth[{f}] != Depth[{f[1]}]
. Does this exist or does someone have a good function for this.
My attempt:
depth := Depth[# //. f_[__] /; ! f === List -> f] &
but I'm sure someone more experienced can do better. (I'm probably forgetting many cases where this would not give the desired result.)