MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

ListDimension function

Hi - I need a short function ListDimension that
given a list returns its "brace dimensionality" =
max number of brace levels to reach deepest entry.

   List         ListDimension
   a+b                   0
   {1,2,x*y}             1
   {1,2,{3,0,1}}         2
   {{},{},{}}            2
   {{},{{1,2}},a}        3

Built-in functions dont seem to be of help.
Dimensions is restricted to matrix or tensor type of lists.
Depth (minus 1) doesnt help as it is entry type dependent:

   Depth[{1,2,3}] -> 2
   Depth[{1,2,3+a}] -> 3
   Depth[{1,2,3+a+Sqrt[x+y]}] -> 5

For the above three, ListDimension=1.

  • Prev by Date: Re: ContainsQ ?
  • Next by Date: Re: ListDimension function
  • Previous by thread: Re: ListDimension function
  • Next by thread: Re: ListDimension function