0

Why level 1,-1,2,3 in a data set containing 10 real numbers are the same? As shown in the following figure!

enter image description here

Lawrence
  • 29
  • 2

1 Answers1

4
SeedRandom[1234];

x = RandomReal[10, 10]

(* {8.76608, 5.21964, 0.862234, 3.77913, 0.116446, 9.27266, 5.43757, 
    4.79332, 2.45349, 7.59896} *)

As stated in the documentation:

Level[x, 0] is a List with no elements

Level[x, 0] === {}

(* True *)

Level[x, {0}] is a List of the whole expression

Level[x, {0}] === {x}

(* True *)

Level[x, n] for positive n is a List of all elements at level 1 through n. Since, in this case, there is only one level

Level[x, 1] === Level[x, 2] === Level[x, 3] === x

(* True *)

Level[x, -1] is a List of all "atomic" (cannot be subdivided) elements

And @@ (AtomQ /@ x)

(* True *)

Since all of the elements of x are atomic

Level[x, -1] === x

(* True *)

Bob Hanlon
  • 157,611
  • 7
  • 77
  • 198