[plt-scheme] implementation of foldl

From: keydana at gmx.de (keydana at gmx.de)
Date: Wed Apr 29 10:38:41 EDT 2009

Hi Thomas,

thanks for your answer.

> Maybe the interface is simply designed this way because it matches the
> signature of cons used as a list constructor naturally.

That's right, I somehow was mislead by the graphic order of cons'  
arguments, I thought Haskell's way was more intuitive, but it's the  
inverse ...
Might be interesting to know if this really was the reason it was  
implemented like that!

In general, I would be curious to know if the following picture of  
fold usage in scheme would be approximately correct:

- for small lists, if a function can be written with foldl and foldlr,  
choose whichever
- more functions can only be written with with foldr because they need  
the empty list at the end
- for very long lists, better use foldl because it uses tail calls


> However I
> don't see any big advantage of that design. On the contrary it makes
> the implementation of the variadic versions of fold and fold-right a
> little more complicated to pass the initial / accumulator argument
> last instead of first.
> cu,
> Thomas
> -- 
> When C++ is your hammer, every problem looks like your thumb.

Posted on the users mailing list.