<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style></head>
<body class='hmmessage'><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>&nbsp; &nbsp; &nbsp; &nbsp; let s = &nbsp;run 50000000 list</div><div>&nbsp; &nbsp; &nbsp; &nbsp; putStrLn $ show s</div></div><div><br></div><div>I want to incrementally update list lot of times, but don'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't know how to tell Haskell not to keep previous</div><div>state rather to release so memory&nbsp;consumption&nbsp;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></body>
</html>