scala 代码随笔

 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 }

 

posted @ 2015-12-29 15:57  澄轶  阅读(154)  评论(0编辑  收藏  举报