Hi Alex.

> If you use a different (but still lazy) definition of foldl:
> > myFoldl f s [] = s
> > myFoldl f s (x:xs) = f s (foldl f x xs)

Unless I'm more asleep than I realise, this is just foldr, isn't it?
(To wit, "fold to the right", rather than "fold to the left".)

In fact, foldr is the "natural" fold, and is usually the one you want
unless:

        o  The folded op is left associative, and not right associative;
        
        o  The op is associative, and strict, and foldl is operationally
           more sensible (as in the foldl' (+) case).

Slainte,
Alex.


Reply via email to