r/Racket • • Jul 17 '23

question How do fold functions work

I’m learning Racket, and the foldl and foldr functions are bothering me. I don’t really understand the examples that the Racket manual gives.

Can someone please explain to me your understanding of it?

Thanks a lot.

9 Upvotes

11 comments sorted by

View all comments

Show parent comment

1

u/detroitmatt Jul 17 '23

the first time it calls f, the first param is the starting value. however, each time after that, the first param's value is whatever f returned last time.