go - How to find the dimensions of a (2,3 or if possible an n)dimensional slice in golang and verify if its a matrix? -


for example : [][]float64{{11, 5, 14, 1}, {11, 5, 14, 1}} has dimensions [2,4].

if passed function efficient way find dimension here?

thanks

the outer dimension len(x) x slice of slices pass function (your example [][]float64{{11, 5, 14, 1}, {11, 5, 14, 1}}). however, inner dimensions not guaranteed equal have go through each element , check len have.

if have guarantee each element of x has same number of elements, find len(x[0]) if len(x) > 0.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -