Skip to content

Instantly share code, notes, and snippets.

@SamuraiT
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SamuraiT/13badf29180a923a3b90 to your computer and use it in GitHub Desktop.
Save SamuraiT/13badf29180a923a3b90 to your computer and use it in GitHub Desktop.
evaluation for simple lisp interpreter
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