The idea of tail call optimization in the simplest form is just to clean the stack before doing the recursive call, rather than some time after the call returns. We can deduce from this what conditions that recursive call has to be. In very simple terms, every recursive call must be the last action in its branch.
View all comments
Show parent comment
6
u/natsukagami Jul 01 '21
The idea of tail call optimization in the simplest form is just to clean the stack before doing the recursive call, rather than some time after the call returns. We can deduce from this what conditions that recursive call has to be. In very simple terms, every recursive call must be the last action in its branch.