summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2018-03-29 06:48:49 -0700
committerKaz Kylheku <kaz@kylheku.com>2018-03-29 06:48:49 -0700
commit3dc8b1a8a57acb24a795750af324970461441cf4 (patch)
tree339328034fd9965d8a4afd654f572a9055880994
parent51b96e84cfa8be259cf42666d23c6dbd239ac44b (diff)
downloadtxr-3dc8b1a8a57acb24a795750af324970461441cf4.tar.gz
txr-3dc8b1a8a57acb24a795750af324970461441cf4.tar.bz2
txr-3dc8b1a8a57acb24a795750af324970461441cf4.zip
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.
-rw-r--r--lib.c10
1 files changed, 9 insertions, 1 deletions
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)