summaryrefslogtreecommitdiffstats
path: root/lib.h
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2018-03-29 06:45:17 -0700
committerKaz Kylheku <kaz@kylheku.com>2018-03-29 06:45:17 -0700
commit706e9bc7983ebb54cfbd7f95b1e98252dfd0d558 (patch)
tree86422b089d1b08600328641aa7e97e0fa0366ad8 /lib.h
parent37b9e093822a7cb4d813b5ea41d6097cce54de33 (diff)
downloadtxr-706e9bc7983ebb54cfbd7f95b1e98252dfd0d558.tar.gz
txr-706e9bc7983ebb54cfbd7f95b1e98252dfd0d558.tar.bz2
txr-706e9bc7983ebb54cfbd7f95b1e98252dfd0d558.zip
lib: eliminate reduce-left from n-ary math ops.
Using reduce-left is inefficient; it conses up a list. We can decimate the stacked arguments without consing. * lib.c (nary_op): Replace reduce_left with iteration. (nary_simple_op): New function, variant of nary_op useable by functions that have a mandatory argument passed separately from the argument list. (minusv, divv): Replace reduce_left with iteration. (maxv, minv): Replace reduce_left with nary_simple_op. (abso_self): New static function. (gcdv, lcmv): Replace reduce_left with nary_op. * lib.h (nary_simple_op): Declared.
Diffstat (limited to 'lib.h')
-rw-r--r--lib.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib.h b/lib.h
index f5e4194f..f39f075a 100644
--- a/lib.h
+++ b/lib.h
@@ -661,6 +661,8 @@ val numberp(val num);
val nary_op(val self, val (*bfun)(val, val),
val (*ufun)(val self, val),
struct args *args, val emptyval);
+val nary_simple_op(val self, val (*bfun)(val, val),
+ struct args *args, val emptyval);
val plus(val anum, val bnum);
val plusv(struct args *);
val minus(val anum, val bnum);