[email protected]
[Top] [All Lists]

[Haskell-cafe] Re: Why doesn't laziness save the day here?

Subject: [Haskell-cafe] Re: Why doesn't laziness save the day here?
From: Dale Jordan
Date: Thu, 07 Jan 2010 11:35:32 -0800
[email protected] wrote:
The others have already pointed out the problem with the imperative
solution, which used the mutation of the global state with the new
random seed. Imperative approach is indeed often a problem.

As Daniel Fischer pointed out, my immediate problem was that iterateR never finished, even though it did produce results lazily. I missed the subtlety that access to results didn't mean access to the state.
There is a simple solution however.
[Snipped ASCII art of head exploding...]

module RList where

[Nice code snipped]

So, if I may paraphrase, oleg's solution works by reifying the implicit continuation in my iterateR's recursive definition into a data structure that is explicitly forced with pullR and its callers. Fascinating...
Thanks to all who responded.

Dale

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

<Prev in Thread] Current Thread [Next in Thread>