[Haskell-cafe] How to incrementally update list

Branimir Maksimovic bmaxa at hotmail.com
Sat Dec 1 09:02:55 CET 2012


I want to simulate some calculation that does that.For example n-body simulation.Anyway this is solved ;)

> Date: Fri, 30 Nov 2012 13:25:57 -0800
> Subject: Re: [Haskell-cafe] How to incrementally update list
> From: kc1956 at gmail.com
> To: bmaxa at hotmail.com
> CC: haskell-cafe at haskell.org
> 
> Why do you want to incrementally update this list a lot of times?
> 
> The question would affect the answer you get; i.e. some context
> (non-monadically speaking). :D
> 
> 
> On Wed, Nov 28, 2012 at 3:43 AM, 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
> > managable.
> >
> > Is there some solution to this problem as I think it is rather
> > common?
> >
> >
> > _______________________________________________
> > Haskell-Cafe mailing list
> > Haskell-Cafe at haskell.org
> > http://www.haskell.org/mailman/listinfo/haskell-cafe
> >
> 
> 
> 
> -- 
> --
> Regards,
> KC
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20121201/fda47380/attachment.htm>


More information about the Haskell-Cafe mailing list