+ 5

Array depth

So im writing this code and i figured out i needed something,how to calculate array depth.There are multidimensional arrays,the problem is,how do i calculate an arrays deepest dimension. e.g arr=[ [ [1,2],[3,4] ],6,4,3,7]; as you can see this arrays dimension is three.but if i have arrays with several dimensions how do i find it? e.g2 arr=[ [1,2],[3,4] ]; this is a 2d array,and so on.Im creating arrays with 20+ dimensions and i need a way of figuring out the arrays dimension,thanks.

19th Apr 2018, 7:29 PM
᠌᠌Code X
᠌᠌Code X - avatar
3 Respostas
+ 3
19th Apr 2018, 9:27 PM
John Wells
John Wells - avatar
+ 4
Sorry for sending links without explanation. These should help: For C#.NET: https://msdn.microsoft.com/en-us/library/system.array.length(v=vs.110).aspx For Python: https://stackoverflow.com/a/3061789/5087494 For Javascript: https://stackoverflow.com/a/10237736/5087494
19th Apr 2018, 10:15 PM
David Carroll
David Carroll - avatar
+ 2
In C++, it strongly depends and I need your exact data structure to tell you how it's possible or how to work around it.
20th Apr 2018, 9:42 AM
Timon Paßlick