Last active
August 29, 2015 14:11
-
-
Save SamuraiT/13badf29180a923a3b90 to your computer and use it in GitHub Desktop.
evaluation for simple lisp interpreter
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 eval(x, env=global_env): | |
if isinstance(x, Symbol): | |
return env[x] | |
elif not isinstance(x, List): | |
return x | |
else: | |
proc = eval(x[0], env) | |
args = [eval(arg, env) for arg in x[1:]] | |
return proc(*args) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment