Skip to content

Instantly share code, notes, and snippets.

@dborovikov
Created March 18, 2015 12:09
Show Gist options
  • Save dborovikov/2465637098c17c3a5425 to your computer and use it in GitHub Desktop.
Save dborovikov/2465637098c17c3a5425 to your computer and use it in GitHub Desktop.
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