Forked from dborovikov/gist:2465637098c17c3a5425
Last active
August 29, 2015 14:17
-
-
Save crmaxx/f09dc6dd9e87865cd63c 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