A ragged list is a (finite depth) list where each element is either a positive integer or a ragged list.
A ragged list is properly tiered if it contains either all positive integers or all properly tiered ragged lists.
For example [1,2,3,6]
is properly tiered because it is a list of only positive integers. [[1,2],[[1]],[[6],[[]]]]
is also properly tiered, because it has 3 elements which are all properly tiered lists themselves. Note that all the lists don't have to be the same depth.
The list [[1,2],[[6],4]]
is not properly tiered because one of it's elements is a ragged list which contains a mixture of lists and positive integers.
Task
Take a ragged list via any natural format and determine if it is a properly tiered list. You should output one of two consistent values, the first if the input is a properly tiered list and the second if it is not.
This is code-golf so your goal is to minimize the size of your source code as measured in bytes.
Test cases
[] -> Yes
[1,2,3,6] -> Yes
[[1,2],[[1]],[[6],[[]]]] -> Yes
[[]] -> Yes
[1,[2]] -> No
[[1,2],[[6],4]] -> No
[[1,[2]],[[3],4]] -> No
[1,[]] -> No
[[1,[2]],[[3],4]]
properly tiered? Both lists contain both lists and numbers. \$\endgroup\$