[Haskell-cafe] Optimization fun
wchogg at gmail.com
Sat Feb 10 16:46:29 EST 2007
On 2/10/07, Creighton Hogg <wchogg at gmail.com> wrote:
> On 2/10/07, Lennart Augustsson <lennart at augustsson.net> wrote:
> > There are many things that makes your code slow.
> > * The default for Haskell is to compute with Integer, not Int. So
> > that makes from Integral and floor very slow.
> > * foldl' is a bad choice, because it is too strict, you want to abort
> > the loop as soon as possible.
> Now why is foldl' too strict? I don't think I understand?
I think I can explain my confusion better. For a finite list, I thought a
fold would always pass through the entire list. I take it that what you
mean is that, since the fold is over an &&, then it can bail as soon as it
encounters the first false, but it only does that if it's allowed to not be
strict. I suppose this reveals my ignorance of how laziness really works.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe