title: Scala: map on zipped lists unclear
body: <p>For an assignment, I had to write a function</p>
  
  <pre><code>zipWith[A,B,C](f:Function2[A,B,C], l1:List[A], l2:List[B]) : List[C]
  </code></pre>
  
  <p>that takes two lists and a function and returns another list.
  ex:</p>
  
  <pre><code>zipWith((x: Int, y: Int) =&gt; x + y, List(1, 2, 3), List(4, 5, 6))
      → List(5, 7, 9)
  </code></pre>
  
  <p>So I went at it and zipped l1 and l2 and tried to map the resulting list:</p>
  
  <pre><code>(l1 zip l2) map ((x:A, y:B) =&gt; f(x,y))
  </code></pre>
  
  <p>giving a "type mismatch: found: (A,B) => C, required: ((A,B)) => ?"</p>
  
  <p>I researched for a bit and found two solution, but I don't understand why exactly this works:</p>
  
  <pre><code>(l1, l2).zipped map ((x:A, y:B)) =&gt; f(x,y))
  </code></pre>
  
  <p>I checked in REPL: </p>
  
  <pre><code>l1 zip l2 =&gt; List[(A, B)] 
  </code></pre>
  
  <p>while </p>
  
  <pre><code>(l1, l2).zipped =&gt; scala.runtime.Tuple2Zipped[A,List[A],B,List[B]] 
  </code></pre>
  
  <p>which, in my eyes, doesn't look more like ((A,B)) than (A,B)?</p>
  
  <p>Can somebody explain?</p>
  
  <p>The other solution,</p>
  
  <pre><code>(l1 zip l2) map { case (x, y) =&gt; f(x, y) }
  </code></pre>
  
  <p>involves a concealed type of pattern matching (or so I understand) which I'm not supposed to use for the assignment.</p>