Skip to content

Instantly share code, notes, and snippets.

@milesrout
Created September 27, 2016 01:47
Show Gist options
  • Save milesrout/e88592422e71183547622a4e87ee7170 to your computer and use it in GitHub Desktop.
Save milesrout/e88592422e71183547622a4e87ee7170 to your computer and use it in GitHub Desktop.
class Env(BaseEnv):
def __init__(self, bindings=None):
super().__init__({
# syntactic forms
'let': syntaxLet,
'lambda': syntaxLambda,
'quote': syntaxQuote,
'exact-number': syntaxExact,
'inexact-number': syntaxInexact,
'set!': syntaxSetBang,
'if': syntaxIf,
# primitive functions
'list': primList,
'+': primPlus,
'-': primMinus,
'*': primTimes,
'/': primDivide,
'car': evaluate(read("(lambda ((x . y)) x)"), BaseEnv({ 'lambda': syntaxLambda })),
'cdr': evaluate(read("(lambda ((x . y)) y)"), BaseEnv({ 'lambda': syntaxLambda })),
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment