From 2ac4413376776ab831cd68d83b9359d272017f9d Mon Sep 17 00:00:00 2001 From: Brian Guarraci Date: Wed, 26 Jul 2023 15:12:01 -0600 Subject: [PATCH] simplify eval --- klongpy/interpreter.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/klongpy/interpreter.py b/klongpy/interpreter.py index 457f817..ec5d120 100644 --- a/klongpy/interpreter.py +++ b/klongpy/interpreter.py @@ -543,7 +543,6 @@ def eval(self, x): * Functions (KGFn) are not invoked unless they are KGCall instances, allowing for function definitions to be differentiated from invocations. """ - if isinstance(x, KGSym): try: return self._context[x] @@ -551,8 +550,6 @@ def eval(self, x): if x not in reserved_fn_symbols: self._context[x] = x return x - elif isinstance(x, KGCall) and not (x.is_op() or x.is_adverb_chain()): - return self._eval_fn(KGFn(x.a,x.args,x.arity)) elif isinstance(x, KGFn): if x.is_op(): f = self._get_op_fn(x.a.a, x.a.arity) @@ -562,6 +559,8 @@ def eval(self, x): return f(_x) if x.a.arity == 1 else f(_x, _y) elif x.is_adverb_chain(): return chain_adverbs(self, x.a)() + elif isinstance(x, KGCall): + return self._eval_fn(x) elif isinstance(x, KGCond): q = self.call(x[0]) p = not ((is_number(q) and q == 0) or is_empty(q))