Closed GoogleCodeExporter closed 9 years ago
Here is an example program that causes a stack overflow due to lazy resolution:
type Step = Empty() | Item(_, _)
def cons(x, s) = lambda () = Item(x, s)
val nil = lambda () = Empty()
def mapStream(f, s) = lambda () = mapStep(s())
def mapStep(f, Empty()) = Empty()
def mapStep(f, Item(x, t)) = Item(f(x), mapStream(f, t))
def zipStreams(f, s, t) = lambda () = zipSteps(f, s(), t())
def zipSteps(f, _, Empty()) = Empty()
def zipSteps(f, Empty(), _) = Empty()
def zipSteps(f, Item(x, s), Item(y, t)) = Item(f(x,y), zipStreams(f, s, t))
def sumStreams(s, t) = zipStreams((+), s, t)
def fib() = sumStreams(cons(0, fib), cons(0, cons(1, fib)))()
def metroStep(Empty()) = -1
def metroStep(Item(x, s)) = x | Rwait(1000) >> metroStream(s)
def metroStream(s) = s() >i> metroStep(i)
def nats(n) = lambda () = Item(n, nats(n+1))
metroStream(fib)
Original comment by dkitc...@gmail.com
on 1 Dec 2012 at 6:15
This issue was closed by revision r3161.
Original comment by arthur.peters
on 20 Jan 2013 at 6:46
Original issue reported on code.google.com by
arthur.peters
on 29 Nov 2012 at 9:11