title: Comparing 2 lists together in Kotlin
body: <p>I've these 2 lists:</p>
  
  <pre><code>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)
  </code></pre>
  
  <p>And need to calculate the forecast error in each month, which is <code>forecast-actual</code>, so I tried the below:</p>
  
  <pre><code>var errors: MutableList&lt;Double&gt; = mutableListOf&lt;Double&gt;()
  
  actual
        .forEachIndexed { index, d -&gt;  forecast[index] - d}
        .let { i -&gt; errors.add(i) }
  </code></pre>
  
  <p>But did not work, as the <code>i</code> resulted from <code>forEachIndexed</code> is a <code>Unit</code> not a <code>Double</code> :( </p>