Advertisement
Guest User

Untitled

a guest
May 1st, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.37 KB | None | 0 0
  1. object Splitterator {
  2.   class Splitterator[T](it: Iterator[T]) {
  3.     def splitWhen(f: T => Boolean): Iterator[Iterator[T]] = {
  4.       new Iterator[Iterator[T]] {
  5.         override def hasNext: Boolean = it.hasNext
  6.  
  7.         override def next(): Iterator[T] = it.takeWhile(f)
  8.       }
  9.     }
  10.   }
  11.  
  12.   implicit def splitterator[T](it: Iterator[T]) = new Splitterator[T](it)
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement