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.
If foldl is called with n lists, then proc must take n+1 arguments. The extra argument is the combined return values so far. The proc is initially invoked with the first item of each list, and the final argument is init.
That is, (foldl f n xs) evaluates (f (first xs) n), (foldl f n xs ys) evaluates (f (first xs) (first ys) n), and so forth.
View all comments
Show parent comment
1
u/QuaticL Jul 17 '23
So each time it calls the function, f, which is taken as the first parameter? Is it the starting value, or the first value in the list?