Skip to content

Instantly share code, notes, and snippets.

@globulon
Created March 31, 2012 18:18
Show Gist options
  • Select an option

  • Save globulon/2267313 to your computer and use it in GitHub Desktop.

Select an option

Save globulon/2267313 to your computer and use it in GitHub Desktop.
Alternate Iteratees
def drop1Keep1[E]: IterV[E, Option[E]] = for {
_: Unit <- drop[E](1)
h: Option[E] <- head[E]
} yield h
def repeat[E, A](iter: IterV[E, A], n: Int): IterV[E, List[A]] = {
type P[X] = IterV[E, X]
implicit val appl = iterateesToApplicative[E]()
replicateM[A, P, List](iter, n)
}
println(run(enum(repeat(drop1Keep1[Int], 5), List(1,2,3,4,5,6,7,8,9,10))).flatten.flatten)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment