diff --git a/silly_thing.py b/silly_thing.py index 0c57ded..024f80e 100644 --- a/silly_thing.py +++ b/silly_thing.py @@ -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)