Given a recursive function, is there some simple way to display or store the value of recursion or "how many levels deep" the function is at a given time?
For instance, if we wrote the recursive function to calculate the factorial of a number (for any positive integer x):
r[x_] := If[x > 0, x*r[x - 1], 1]
Is there some way to output, as the function evaluates that it is a level "n"?
Given that the
$RecursionLimit determines the max number of times a function can call itself nested, there must be some flag or value stored to keep track of how deep the current evaluation is that is compared to
$RecursionLimit, that, if exceeded, aborts. What is this flag/value?