On Tue, May 29, 2007 at 12:15:23PM +0200, Vincent Kraeutler wrote:
> Donald Bruce Stewart wrote:
> > P.S. Have some cute code:
> > Control.Monad.Fix.fix ((1:) . scanl (+) 1)
> this is cute indeed! (do you keep an emergency reserve of those around
> for situations like this? ;-))
> ever the interested amateur, i admittedly remain stumped by fix (there's
> evidence i'm not the only one )
The above code is equivalent to
let l = 1 : scanl (+) 1 l in l
which is a bit easier to decipher.
The rest is maths and the subtleties of lazy evaluation.
Haskell-Cafe mailing list