3 ms·
Not unless it's the loop is made out several function calls. For example: def even(x): return x == 0 ? True : odd(x - 1) def odd(x): r
by Joker_vD 6y ago
Not unless it's the loop is made out several function calls. For example:
def even(x):
return x == 0 ? True : odd(x - 1)
def odd(x):
return x == 0 ? False : even(x - 1)
print(even(17))
Properly implemented TCO means that the call to 'even(17)' should use only one stack frame.
- phoe-krk 6y ago> Properly implemented TCO Such is the case e.g. in Erlang/BEAM.