Don't use recursion in evaluate :(
This commit is contained in:
parent
d94ff158f7
commit
f5d999a3dd
|
@ -28,15 +28,14 @@ def evaluate(expr: Expression) -> Expression:
|
|||
>>> evaluate(Application((funktion, Int(0))))
|
||||
1312
|
||||
"""
|
||||
if expr.is_value():
|
||||
return expr
|
||||
else:
|
||||
while not expr.is_value():
|
||||
match expr.step():
|
||||
case Some(next):
|
||||
return evaluate(next)
|
||||
expr = next
|
||||
# Loop
|
||||
case None:
|
||||
raise AssertionError('Evaluate called on a value which cannot step:', expr)
|
||||
raise Exception('Unreachable')
|
||||
return expr
|
||||
|
||||
def repl_expr(expr: Expression, bindings: ReplHole = ReplHole(BUILTINS_CONTEXT)):
|
||||
expr_subst = subst_all(bindings.val_bindings, expr)
|
||||
|
|
Loading…
Reference in a new issue