Skip to content

Instantly share code, notes, and snippets.

@non
Created September 12, 2012 01:36
Show Gist options
  • Select an option

  • Save non/3703562 to your computer and use it in GitHub Desktop.

Select an option

Save non/3703562 to your computer and use it in GitHub Desktop.
object Implicits {
implicit def xyz[A](as:Stream[A]) = new {
def takeThrough(p:A => Boolean) = tt(as)
def tt[A](as:Stream[A], p:A => Boolean):Stream[A] = as match {
case h #:: t => Stream.cons(h, if (p(h)) tt(t) else Stream.Empty)
case e => e
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment