Created
June 5, 2011 15:37
-
-
Save markhibberd/1009060 to your computer and use it in GitHub Desktop.
Int Enumerator
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
import scalaz._, Scalaz._ | |
import IterV._ | |
// something to generate a stream that will be enough to blow the stack.... | |
def ints[A]: (Int, Int) => IterV[Int, A] => IterV[Int, A] = (start, end) => iter => { | |
def loop(s: Int, i: IterV[Int, A]): IterV[Int, A] = i match { | |
case Done(_, _) => i | |
case Cont(k) => | |
if (s > end) | |
i | |
else | |
loop(s + 1, k(El(s))) | |
} | |
loop(start, iter) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment