[Haskell-cafe] How to incrementally update list
edwards.benj at gmail.com
Wed Nov 28 13:07:49 CET 2012
TCO + strictnesses annotations should take care of your problem.
On 28 Nov 2012 11:44, "Branimir Maksimovic" <bmaxa at hotmail.com> wrote:
> Problem is following short program:
> list = [1,2,3,4,5]
> advance l = map (\x -> x+1) l
> run 0 s = s
> run n s = run (n-1) $ advance s
> main = do
> let s = run 50000000 list
> putStrLn $ show s
> I want to incrementally update list lot of times, but don't know
> how to do this.
> Since Haskell does not have loops I have to use recursion,
> but problem is that recursive calls keep previous/state parameter
> leading to excessive stack.and memory usage.
> I don't know how to tell Haskell not to keep previous
> state rather to release so memory consumption becomes
> Is there some solution to this problem as I think it is rather
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe