Convert Array[Array[Double]] to Array[Double]

665 Views Asked by At

How can I convert an array of arrays of doubles to just an array of doubles using Scala 2.10.4?

Convert: Array[Array[Double]] => Array[Double]

2

There are 2 best solutions below

0
On BEST ANSWER

Use flatten:

val r: Array[Double] = doubleDouble.flatten
0
On

You can write something like this:

val src = Array(Array(1.2,3.4), Array(5.6, 7.8))

val result = for {
a <- src
b <- a
} yield b