summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--eval.c2
-rw-r--r--lib.c17
-rw-r--r--lib.h1
-rw-r--r--txr.18
4 files changed, 25 insertions, 3 deletions
diff --git a/eval.c b/eval.c
index e83a8954..34d73304 100644
--- a/eval.c
+++ b/eval.c
@@ -4776,7 +4776,7 @@ void eval_init(void)
reg_fun(intern(lit("trunc-rem"), user_package), func_n2(trunc_rem));
reg_fun(intern(lit("wrap"), user_package), func_n3(wrap));
reg_fun(intern(lit("wrap*"), user_package), func_n3(wrap_star));
- reg_fun(intern(lit("/"), user_package), func_n2o(divi, 1));
+ reg_fun(intern(lit("/"), user_package), func_n1v(divv));
reg_fun(intern(lit("expt"), user_package), func_n0v(exptv));
reg_fun(intern(lit("exptmod"), user_package), func_n3(exptmod));
reg_fun(intern(lit("isqrt"), user_package), func_n1(isqrt));
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);
diff --git a/lib.h b/lib.h
index 83b81c24..c07bc863 100644
--- a/lib.h
+++ b/lib.h
@@ -602,6 +602,7 @@ val neg(val num);
val abso(val num);
val mul(val anum, val bnum);
val mulv(struct args *);
+val divv(val dividend, struct args *);
val trunc(val anum, val bnum);
val mod(val anum, val bnum);
val trunc_rem(val anum, val bnum);
diff --git a/txr.1 b/txr.1
index dcf89f40..30017711 100644
--- a/txr.1
+++ b/txr.1
@@ -26837,7 +26837,7 @@ A character may not be an operand of multiplication.
.coNP Functions @, / @ trunc, @ mod and @ trunc-rem
.synb
-.mets (/ <> [ dividend ] << divisor )
+.mets (/ <> [ dividend ] << divisor *)
.mets (trunc < dividend << divisor )
.mets (mod < dividend << divisor )
.mets (trunc-rem < dividend << divisor )
@@ -26853,7 +26853,11 @@ converted to floating-point type, if necessary. If
is omitted,
then it is taken to be
.code 1.0
-and the function calculates the reciprocal.
+and the function calculates the reciprocal. Of these division functions,
+only this one may be called with just one argument, or with more than two
+arguments. If there are more than two arguments, then each additional argument
+is treated as an additional divisor which further divides the result of the
+division by the previous divisors.
The
.code trunc