title: Scala: Creating a list of tuples from list elements sequentially
body: <p>I am very new to Scala so this question may be very naive.</p>
  
  <p>I have a list like this <code>List[Int] = List(0, 3, 6, 12, 14, 15, 16, 17)</code>. I am trying to create a list like this <code>[(0,3),(3,6),(6,12)..]</code> and so on. So far this is what I have tried:</p>
  
  <pre><code>val l1= List(0, 3, 6, 12, 14, 15, 16, 17)
  var l2=scala.collection.mutable.ListBuffer[(Int,Int)]()
  l1.zipWithIndex.slice(0,l1.length-1).foreach(x=&gt;{val newval=(x._1,l1(x._2+1)); l2+=newval})
  </code></pre>
  
  <p>Two questions here:</p>
  
  <ol>
  <li>If I don't use <code>val newval</code>, i.e. try to do <code>l1.zipWithIndex.slice(0,l1.length-1).foreach(x=&gt;l2+=(x._1,l1(x._2+1)))</code>, the compiler says: 
  <code>&lt;console&gt;:10: error: type mismatch;
  found   : Int
  required: (Int, Int)
            l1.zipWithIndex.slice(0,l1.length-1).foreach(x=&gt;l2+=(x._1,l1(x._2+1)))</code>. Why is that?</li>
  <li>What would a way to do it without the mutable listbuffer?</li>
  </ol>