summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-01-13 23:31:16 -0800
committerKaz Kylheku <kaz@kylheku.com>2016-01-13 23:31:16 -0800
commite54cd7d4d63d866bf17576d3cac72d6ae51cbcfa (patch)
treee35722efff193a2af3597c5d484e35fa44d7b3e4 /lib.c
parent4433aa4b693a9d0246788aff9acb12a8470edf6f (diff)
downloadtxr-e54cd7d4d63d866bf17576d3cac72d6ae51cbcfa.tar.gz
txr-e54cd7d4d63d866bf17576d3cac72d6ae51cbcfa.tar.bz2
txr-e54cd7d4d63d866bf17576d3cac72d6ae51cbcfa.zip
Fix omission: the / function becomes n-ary.
* eval.c (eval_init): Register / function to divv instead of divi. * lib.c (divv): New function. * lib.h (divv): Declared. * txr.1: Documented.
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib.c b/lib.c
index c0c8b5de..2000349c 100644
--- a/lib.c
+++ b/lib.c
@@ -2650,6 +2650,23 @@ val mulv(struct args *nlist)
return nary_op(mul, nlist, one);
}
+val divv(val dividend, struct args *nlist)
+{
+ cnum index = 0;
+ val fi;
+
+ if (!args_more(nlist, 0))
+ return divi(one, dividend);
+
+ fi = args_get(nlist, &index);
+
+ if (!args_more(nlist, 0))
+ return divi(dividend, fi);
+
+ return reduce_left(func_n2(divi), args_get_list(nlist),
+ divi(dividend, fi), nil);
+}
+
val logandv(struct args *nlist)
{
return nary_op(logand, nlist, negone);