[Haskell-cafe] turning an imperative loop to Haskell

Henning Thielemann lemming at henning-thielemann.de
Thu Sep 6 11:15:01 EDT 2007


On Thu, 6 Sep 2007, Axel Gerstenberger wrote:

> Thanks to all of you. The suggestions work like a charm. Very nice.
>
> I still need to digest the advices, but have already one further question: 
> How would I compute the new value based on the 2 (or even more) last values 
> instead of only the last one?
>
> [ 2, 3 , f 3 2, f((f 3 2) 3), f ( f((f 3 2) 3)  f 3 2)), ...]
>
> (background: I am doing explicit time stepping for some physical problem, 
> where higher order time integration schemes are interesting. You advance in 
> time by extrapolating based on the old time step values.)

You might be interested in some ideas on how to solve differential 
equations numerically in an elegant way:
  http://darcs.haskell.org/htam/src/Numerics/ODEEuler.lhs


More information about the Haskell-Cafe mailing list