I am a beginner in F#, and I am still having trouble wrapping my head around the concept of the tail recursion. Specifically, I do not know how tail recursion works since neither is there any value associated with the accumulator, nor is the accumulator ever defined.
Here is some sample code for a tail recursive function for computing a factorial
let factorial x =
// Keep track of both x and an accumulator value (acc)
let rec tailRecursiveFactorial x acc =
if x <= 1 then
acc
else
tailRecursiveFactorial (x - 1) (acc * x)
tailRecursiveFactorial x 1
I am not asking for how to write a tail recursive function, nor am I asking for examples of tail and non-tail recursive functions. What I am asking is how the accumulator works since it is never defined