From fd96bd149ed3f0e7ee899d058f42a558247028f8 Mon Sep 17 00:00:00 2001 From: cynic Date: Mon, 7 Nov 2022 13:22:30 -0500 Subject: [PATCH] exponentiation as builtin --- lib.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib.py b/lib.py index 0f03c5d..2b10240 100644 --- a/lib.py +++ b/lib.py @@ -83,6 +83,8 @@ def execute(program): return reduce(lambda a, b: (a[0], a[1]*b[1]), subs[1:]) elif ctx[0] == _ident("/"): return reduce(lambda a, b: (a[0], a[1]/b[1]), subs[1:]) + elif ctx[0] == _ident("^"): + return reduce(lambda a, b: (a[0], a[1]**b[1]), subs[1:]) elif ctx[0] == _ident("=="): return ("number", 1.0 if subs[1] == subs[2] else 0.0) elif ctx[0] == _ident("="):