Created
March 31, 2012 18:18
-
-
Save globulon/2267313 to your computer and use it in GitHub Desktop.
Alternate Iteratees
This file contains hidden or 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 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