Created
August 17, 2020 01:11
-
-
Save sagnibak/0412b44e768703752aad9e0a65ae27cc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def tco(fn): | |
def inner(*args, **kwargs): | |
result = fn(*args, **kwargs) | |
while isinstance(result, TailCall): | |
result = fn(*result.args, **result.kwargs) | |
else: | |
return result.return_val | |
return inner |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment