Tail Recursion Trace

The trace feature can be used to see the sequence of recursive calls to factorialb. Note that the final answer is returned unchanged. In this case, the argument also serves as a state variable; the function counts down the argument as it builds up the answer.


: (trace factorial factorialb)

: (factorial 3) Entry (factorial 3) |Entry (factorialb 3 1) | Entry (factorialb 2 3) | Entry (factorialb 1 6) | |Entry (factorialb 0 6) | |==> 6 | ==> 6 | ==> 6 |==> 6 ==> 6 6

Contents    Page-10    Prev    Next    Page+10    Index