Skip to content

Commit c93076a

Browse files
committed
sync from Atlas
2 parents 2f2f87d + 3ecfb21 commit c93076a

File tree

1 file changed

+8
-1
lines changed
  • 18-with-match/lispy/py3.10

1 file changed

+8
-1
lines changed

18-with-match/lispy/py3.10/lis.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,10 @@ def lispstr(exp: object) -> str:
140140
################ Evaluator
141141

142142
# tag::EVALUATE[]
143-
KEYWORDS = ['quote', 'if', 'lambda', 'define', 'set!']
143+
KEYWORDS = {'quote', 'if', 'lambda', 'define', 'set!'}
144+
145+
def is_keyword(s: Any) -> bool:
146+
return isinstance(s, Symbol) and s in KEYWORDS
144147

145148
def evaluate(exp: Expression, env: Environment) -> Any:
146149
"Evaluate an expression in an environment."
@@ -164,7 +167,11 @@ def evaluate(exp: Expression, env: Environment) -> Any:
164167
env[name] = Procedure(parms, body, env)
165168
case ['set!', Symbol(var), value_exp]:
166169
env.change(var, evaluate(value_exp, env))
170+
<<<<<<< HEAD
167171
case [func_exp, *args] if func_exp not in KEYWORDS:
172+
=======
173+
case [func_exp, *args] if not is_keyword(func_exp):
174+
>>>>>>> 3ecfb212c6273122797c76876d6b373b2cb94fa6
168175
proc = evaluate(func_exp, env)
169176
values = [evaluate(arg, env) for arg in args]
170177
return proc(*values)

0 commit comments

Comments
 (0)