[plt-scheme] Behavior of foldl

From: Jean-Paul ROY (roy at unice.fr)
Date: Sun Jul 9 13:48:55 EDT 2006

It seems that the behavior of foldl is non standard with respect to  
most functional programming languages.
Il should be the iterative version of foldr, working from left to  
right :

  (define (foldl f e L)
     (define (iter acc L)
       (if (null? L)
           (iter (f acc (car L)) (cdr L))))
     (iter e L))

 > (foldl (lambda (x y) (+ (* 2 x) y)) 4 '(1 2 3))

But the fold defined in list.ss has not this behavior and returns 16.

See example 5 in http://www.zvon.org/other/haskell/Outputprelude/ 

Am i wrong ?

     Jean-Paul Roy

Posted on the users mailing list.