[Haskell-cafe] foldl vs foldl'
Simon Richard Clarkstone
simon.clarkstone at gmail.com
Sun Nov 9 19:24:37 EST 2008
Bas van Dijk wrote:
> On Wed, Nov 5, 2008 at 12:43 AM, Bas van Dijk <v.dijk.bas at gmail.com> wrote:
>> 2008/11/5 Daryoush Mehrtash <dmehrtash at gmail.com>:
>>> Are there cases (function or list) where the result of foldl (or foldr)would
>>> be different that foldl' (or foldr')?
>> Maybe this wiki article I wrote some time ago will answer your question:
>>
>> http://haskell.org/haskellwiki/Foldr_Foldl_Foldl'
>
> Oops that link should be:
>
> http://haskell.org/haskellwiki/Foldr_Foldl_Foldl%27
I have an idea for the foldl diagram. If you rotate the RHS 90deg
clockwise, it slopes the same way as the original list, but the 'f's are
still rotated sideways to signify which their inputs are. That makes
the relationship between imperative accumulator loops and foldl a bit
clearer to me, as well as the relationship between the list and the
recursion structure.
--
src/
More information about the Haskell-Cafe
mailing list