Tail Call Optimisation
- Tags
- comp-arch
Is an optimisation technique for recursive functions where you can collapse multiple stack frames into a single stack frame that's reused for each recursive call.
def fac(i):
if i <= 0:
return 1
return i * fac(i - 1)
Code Snippet 1:
Example of a recursive function that could use tail-call optimisation. tail-call
In