title: Use map and zip to be more func style in 2 for loops
body: <p>I implemented the following code to calculate weighted avg with for loops, how can I be more func programming style and use <code>map</code> and <code>zip</code>?</p>
  <pre><code>val aggAvg = (emb: Seq[Seq[Float]], weights: Seq[Float]) =&gt; {
        val embSize = emb.head.size
        val len = emb.size
        (0 until embSize)
          .map { i =&gt;
            (0 until len).map { j =&gt;
              emb(j)(i) * weights(j)
            }.sum / weights.sum
          }
      }
  </code></pre>
  <p>Example:
  Given</p>
  <pre><code>val emb: Seq[Seq[Float]] = Seq(Seq(1,2,3), Seq(4,5,6))
  val weights: Seq[Float] = Seq(2, 8)
  </code></pre>
  <p>the output would be <code>Seq(3.4, 4.4, 5.4)</code> because
  <code>(1 * 2 + 4 * 8) / (2 + 8) = 3.4</code> and so on.</p>