[r6rs-discuss] [Formal] asymmetry between fold-left and fold-right

John Cowan cowan at ccil.org
Mon Jan 29 01:57:09 EST 2007


Anton van Straaten scripsit:

> Informally and intuitively, the fold-right procedure folds a procedure
> over the elements of a list in right-to-left order, whereas fold-left
> uses left-to-right order.

As a historical note, DTSS Lisp (the first Lisp I ever learned) defined
MINUS as a right-fold:  (MINUS 5) = -5, (MINUS 3 4) = 3 - 4, (MINUS 3 4 5)
= (-3) + 4 + (-5).  There was no left-folded subtraction function.

-- 
John Cowan   http://ccil.org/~cowan    cowan at ccil.org
We want more school houses and less jails; more books and less arsenals;
more learning and less vice; more constant work and less crime; more
leisure and less greed; more justice and less revenge; in fact, more of
the opportunities to cultivate our better natures.  --Samuel Gompers



More information about the r6rs-discuss mailing list