Created
March 18, 2015 12:09
-
-
Save dborovikov/2465637098c17c3a5425 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def takeUpToNot[T](pred: (T) => Boolean): Iteratee[T, Seq[T]] = { | |
def step(ok: Boolean, result: Seq[T])(i: Input[T]): Iteratee[T, Seq[T]] = i match { | |
case Input.EOF | Input.Empty => Done(result, Input.EOF) | |
case Input.El(e) => | |
if (ok) Cont[T, Seq[T]](i => step(pred(e), result :+ e)(i)) | |
else Done(result, Input.EOF) | |
} | |
Cont[T, Seq[T]](i => step(ok = true, Vector())(i)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment