开发者

In a multidimensional sequence created with tabulate, is the innermost seq the 1. dimension?

开发者 https://www.devze.com 2023-01-13 16:09 出处:网络
As the title says, when creating a multidimensional sequence in scala with tabulate, is the innermost or outermost sequence the 1. dimension?

As the title says, when creating a multidimensional sequence in scala with tabulate, is the innermost or outermost sequence the 1. dimension?

For example, in a 2-dimensio开发者_JAVA百科nal Vector v, will v(2) give the second element of the 1. or of the 2. dimension?


scala> Array.tabulate(2,3)(_ + 3*_)
res2: Array[Array[Int]] = Array(Array(0, 3, 6), Array(1, 4, 7))

As you can see, the first number refers to the outermost grouping, while the second refers to the second (and so on). In general, all the multidimensional stuff works this way--if you list the dimensions as 3,5,7,2 then a(2)(4)(6)(1) uses the last valid index in each dimension.

0

精彩评论

暂无评论...
验证码 换一张
取 消