1 def myfunc[T](iter: Iterator[T]) : Iterator[(T, T)] = { 2 var res = List[(T, T)]() 3 var pre = iter.next 4 while (iter.hasNext) { 5 val cur = iter.next; 6 res .::= (pre, cur) 7 pre = cur; 8 } 9 res.iterator 10 }