I’ve these 2 lists:
val forecast = listOf(30, 21, 29, 31, 40, 48, 53, 47, 37, 39, 31, 29)
val actual = listOf(27, 31, 27, 26, 21, 13, 21, 18, 33, 35, 40, 36)
And need to calculate the forecast error in each month, which is forecast-actual
, so I tried the below:
var errors: MutableList<Double> = mutableListOf<Double>()
actual
.forEachIndexed { index, d -> forecast[index] - d}
.let { i -> errors.add(i) }
But did not work, as the i
resulted from forEachIndexed
is a Unit
not a Double