I see this:

> (foldl cons '() '(1 2 3 4))
'(4 3 2 1)

and have to conclude that foldl is reversing the list. This is bolstered by 
this:

(define (my-reverse lst)
  (foldl cons empty lst))

which is a way of reversing a list. Good. But then I see this:

(foldl (lambda (a b result)
         (begin
           (printf "a: ~a, b: ~a, result: ~a\n" a b result)
           (* result (- a b))))
       1
       '(0 2 4 6)
       '(3 4 5 6))

giving this:

a: 0, b: 3, result: 1
a: 2, b: 4, result: -3
a: 4, b: 5, result: 6
a: 6, b: 6, result: -6
0

and I'm not seeing any reversal, right? The input 

1
'(0 2 4 6)
'(3 4 5 6)

seems to only be putting the result variable first. Or am I missing something?

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to