[plt-scheme] implementation of foldl

From: Thomas Chust (chust at web.de)
Date: Tue Apr 28 17:44:08 EDT 2009

2009-04-28 keydana at gmx.de <keydana at gmx.de>:
> [...]
> I am wondering whether the order in which foldl applies the "init" argument
> and the "car" argument to the given combining function is to be regarded as
> specified or as an implementation detail (such that you should not rely on
> it).
> [...]

Hello Sigrid,

since SRFI-1 specifies fold and fold-right such that the combining
function is passed the initialization value as its last argument, I
suppose this is the more common choice in the Scheme world than the
other way around.

Maybe the interface is simply designed this way because it matches the
signature of cons used as a list constructor naturally. 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.