summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2012-03-29 21:41:49 -0700
committerKaz Kylheku <kaz@kylheku.com>2012-03-29 21:41:49 -0700
commit8b8ca2e793f90aa58d7430b8f060c467cd41ec1b (patch)
tree322203f975cfb3b66c67252791bb0ba987253923 /lib.c
parent2b1e05769d01cb036cf0a82231eb87b698a33426 (diff)
downloadtxr-8b8ca2e793f90aa58d7430b8f060c467cd41ec1b.tar.gz
txr-8b8ca2e793f90aa58d7430b8f060c467cd41ec1b.tar.bz2
txr-8b8ca2e793f90aa58d7430b8f060c467cd41ec1b.zip
* arith.c (numeq): New function.
(exptmod): Bugfix: was no normalizing the bignum, ouch. Also was reporting "non-integral operands" for other errors. * eval.c (eval_init): Registered = intrinsic function. * lib.c (numeqv): New function. * lib.h (numeq, numeqv): Declared. * txr.1: Documented expt, sqrt, isqrt, exptmod, fixnump, bignump, integerp, floatp, numberp, zerop, evenp, oddp, >, <, >=, <= and =. * txr.vim: Highlight =
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib.c b/lib.c
index 5737d48e..d354ce6e 100644
--- a/lib.c
+++ b/lib.c
@@ -1269,6 +1269,20 @@ val lev(val first, val rest)
return t;
}
+val numeqv(val first, val rest)
+{
+ val iter;
+
+ for (iter = rest; iter; iter = cdr(iter)) {
+ val elem = car(iter);
+ if (!numeq(first, elem))
+ return nil;
+ first = elem;
+ }
+
+ return t;
+}
+
val max2(val anum, val bnum)
{
return if3(gt(anum, bnum), anum, bnum);