[racket-dev] foldl does a right fold?

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Sat Jul 9 21:59:02 EDT 2011

On Jul 9, 2011, at 8:38 PM, Clark Grubb wrote:

> This seems to be a bug.  Here is the
> Racket behavior and Haskell behavior
> for comparison.
> 
> ======================
> 
> $ racket
> Welcome to Racket v5.1.1.
>> (foldl - 0 '(1 2 3))


John's stepper should show this: 

== (fold - (- 1 0) '(2 3))
== (fold - (- 2 1) '(3))
== (fold - (- 3 1) '())
== 2 

Did you post the same message to the Haskell mailing group? 
Racket's fold heritage is significantly older than Haskell's. 
Is it perhaps possible that Haskell got it wrong? 

-- Matthias














> 2
>> (foldr - 0 '(1 2 3))
> 2
> 
> ======================
> 
> $ ghci
> GHCi, version 6.10.4: http://www.haskell.org/ghc/  :? for help
> Prelude> foldl (-) 0 [1,2,3]
> -6
> Prelude> foldr (-) 0 [1,2,3]
> 2
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/dev



Posted on the dev mailing list.