From cc3496679a84429211981af13aa4ea13b80b1f68 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 29 Mar 2018 06:48:49 -0700 Subject: lib: elminate reduce_right from expt. * lib.c (rexpt): New static function. (exptv): Create reversed arguments on the stack, then process with nary_op and the rexpt shim. --- lib.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib.c b/lib.c index eeaec7b7..b3169d2c 100644 --- a/lib.c +++ b/lib.c @@ -3466,9 +3466,17 @@ val clamp(val low, val high, val num) return max2(low, min2(high, num)); } +static val rexpt(val right, val left) +{ + return expt(left, right); +} + val exptv(struct args *nlist) { - return reduce_right(func_n2(expt), args_get_list(nlist), one, nil); + cnum nargs = args_count(nlist); + args_decl(rnlist, max(ARGS_MIN, nargs)); + args_copy_reverse(rnlist, nlist, nargs); + return nary_op(lit("expt"), rexpt, unary_num, rnlist, one); } static val abso_self(val self, val arg) -- cgit v1.2.3