Somebody please explain the algorithm in this problem for OCaml.
I have the solution but I do not understand it.
Define iterup: (int * 𝛼→𝛼) → int → int →𝛼→𝛼. Iterup takes a function which receives the current number and the accumulator. It increments the counter number from a given start to a given end and applies the function each time. The last argument is the start value of the accumulator.
The solution is
let rec iterup f st ed acc = if st > ed then acc else iterup f (st+1) ed (f st acc)
What I do not understand is why we take in both n and s as arguments to f in the last part (f n s). What does that get us to when we talk in terms of tail recursion.