<p dir="ltr">TCO + strictnesses annotations should take care of your problem.</p>
<div class="gmail_quote">On 28 Nov 2012 11:44, &quot;Branimir Maksimovic&quot; &lt;<a href="mailto:bmaxa@hotmail.com">bmaxa@hotmail.com</a>&gt; wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



<div><div dir="ltr">
Problem is following short program:<div><div>list = [1,2,3,4,5]</div><div><br></div><div>advance l = map (\x -&gt; x+1) l</div><div><br></div><div>run 0 s = s</div><div>run n s = run (n-1) $ advance s</div><div><br></div>
<div>main = do</div><div>        let s =  run 50000000 list</div><div>        putStrLn $ show s</div></div><div><br></div><div>I want to incrementally update list lot of times, but don&#39;t know</div><div>how to do this.</div>
<div>Since Haskell does not have loops I have to use recursion,</div><div>but problem is that recursive calls keep previous/state parameter</div><div>leading to excessive stack.and memory usage.</div><div>I don&#39;t know how to tell Haskell not to keep previous</div>
<div>state rather to release so memory consumption becomes</div><div>managable.</div><div><br></div><div>Is there some solution to this problem as I think it is rather</div><div>common?</div><div><br></div>                                               </div>
</div>
<br>_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
<br></blockquote></div>