Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

But isn't this exactly the same code as above for the reverse accumulation case, where we just substituted foldl for foldr? Does this make sense?

On the other hand, try the following:

Code Block

(foldr cons empty (list 1 2 3 4 5))
(foldl cons empty (list 1 2 3 4 5)) 

Can you explain the difference?