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

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

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

+4
source share
2 answers

Use flatten:

val r: Array[Double] = doubleDouble.flatten
+9
source

You can write something like the following:

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

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

All Articles