How to best iterate over k-dimensional collection, e.g. (n,k) matrix?

Other possible options can be found here (with bonus benchmarking, although they are probably dated):