final double[][] a = new double[][] { { 1, 2, 3 }, { 4, 5, 6 } };
final int numRows = a.length;
final int numCols = a[0].length;
final double[] da = IntStream.range(0, numCols)
.mapToObj(i -> IntStream.range(0, numRows).mapToDouble(j -> a[i][j])).flatMap(d -> d)
.toArray(double[]::new);
// da should be [1, 4, 2, 5, 3, 6]
Error is: Cannot infer type argument(s) for flatMap(Function>)
What is the correct way to write this? I have tried emitting double[] from the map but can't get that to go either. Thanks a bunch.