Re: SRFI-1's fold is not fold-left! Taylor R Campbell (03 Nov 2012 12:39 UTC)
Re: SRFI-1's fold is not fold-left! Taylor R Campbell 03 Nov 2012 12:39 UTC
Date: Sat, 03 Nov 2012 13:17:22 +0100
From: Peter Kourzanov <firstname.lastname@example.org>
> While translating some OCaml code I have come across the following
> discrepancy. Although it is known, it is worthwhile to mention it, I
> think. The SRFI-1's fold is not actually a fold-left (it is mentioned
> in passing in SRFI-1 itself that F's args are flipped w.r.t. MIT-Scheme
> and Haskell).
The only flipping here is the coin you flip when deciding which order
the arguments are supposed to go in when specifying the operation.
Haskell and MIT Scheme do it one way; SML and SRFI 1 do it the other
way. Neither one is the `actual' fold-left; I'm sure you can find
lots more examples of both, under various names including `fold' and
`foldl' and `fold-left' and `reduce'.
Drawing a distinction between `fold [left]' (f xi state) and `fold
left' (f state xi) is likely only to confuse matters further, I
suspect. (E.g., already, in SML, foldl is your `fold [left]' and not
your `fold left'.)