Created
November 3, 2019 23:06
-
-
Save chelseatroy/b3b428811d7c05600bd52b6f95ddb743 to your computer and use it in GitHub Desktop.
Interpreter 1: No Scope (excerpt)
This file contains 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 substitute(exp, name, value): | |
if exp == name: | |
return value | |
elif isinstance(exp, tuple): | |
return tuple([substitute(part, name, value) for part in exp]) | |
else: | |
return exp #Unchanged |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment