summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2012-09-11 19:28:52 -0700
committerKaz Kylheku <kaz@kylheku.com>2012-09-11 19:28:52 -0700
commit46f607ae233a8f71c09d40dd45aae5f2ec7056fc (patch)
tree6c667191e2a3e92eab802854382fd778db6bfa73
parentb597cb4f7bc454f4d8c0bb7df435df1246920273 (diff)
downloadtxr-46f607ae233a8f71c09d40dd45aae5f2ec7056fc.tar.gz
txr-46f607ae233a8f71c09d40dd45aae5f2ec7056fc.tar.bz2
txr-46f607ae233a8f71c09d40dd45aae5f2ec7056fc.zip
* eval.c (eval_init): new instrinsic function /= registered.
* lib.c (numneqv): New function. * lib.h (numneqv): Declared. * txr.1: New function documented.
-rw-r--r--ChangeLog10
-rw-r--r--eval.c1
-rw-r--r--lib.c12
-rw-r--r--lib.h1
-rw-r--r--txr.115
5 files changed, 39 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index dad71696..708bf2c3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2012-09-11 Kaz Kylheku <kaz@kylheku.com>
+
+ * eval.c (eval_init): new instrinsic function /= registered.
+
+ * lib.c (numneqv): New function.
+
+ * lib.h (numneqv): Declared.
+
+ * txr.1: New function documented.
+
2012-09-10 Kaz Kylheku <kaz@kylheku.com>
* match.c (v_collect): Bug in processing of @(last) directive.
diff --git a/eval.c b/eval.c
index 5ef0f34e..9266846b 100644
--- a/eval.c
+++ b/eval.c
@@ -2228,6 +2228,7 @@ void eval_init(void)
reg_fun(intern(lit(">="), user_package), func_n1v(gev));
reg_fun(intern(lit("<="), user_package), func_n1v(lev));
reg_fun(intern(lit("="), user_package), func_n1v(numeqv));
+ reg_fun(intern(lit("/="), user_package), func_n0v(numneqv));
reg_fun(intern(lit("max"), user_package), func_n1v(maxv));
reg_fun(intern(lit("min"), user_package), func_n1v(minv));
diff --git a/lib.c b/lib.c
index 74e64a90..8492c3dc 100644
--- a/lib.c
+++ b/lib.c
@@ -1414,6 +1414,18 @@ val numeqv(val first, val rest)
return t;
}
+val numneqv(val list)
+{
+ val i, j;
+
+ for (i = list; i; i = cdr(i))
+ for (j = cdr(i); j; j = cdr(j))
+ if (numeq(car(i), car(j)))
+ return nil;
+
+ return t;
+}
+
val max2(val anum, val bnum)
{
return if3(ge(anum, bnum), anum, bnum);
diff --git a/lib.h b/lib.h
index eedaa1cb..d454fd29 100644
--- a/lib.h
+++ b/lib.h
@@ -450,6 +450,7 @@ val ltv(val first, val rest);
val gev(val first, val rest);
val lev(val first, val rest);
val numeqv(val first, val rest);
+val numneqv(val list);
val max2(val anum, val bnum);
val min2(val anum, val bnum);
val maxv(val first, val rest);
diff --git a/txr.1 b/txr.1
index 6323f6a9..c4ede065 100644
--- a/txr.1
+++ b/txr.1
@@ -8377,6 +8377,21 @@ undergo two different conversions. For instance in (< <float> <character>
its Unicode, and if that comparison suceeds, then in the second comparison, the
character will convert to integer.
+.SS Function /=
+
+.TP
+Syntax:
+
+ (/= <number>*)
+
+.TP
+Description:
+
+The arguments to /= may be numbers or characters. The /= function returns t if
+no two of its arguments are numerically equal. That is to say, if there exist
+some a and b which are distinct arguments such that (= a b) is true, then
+teh function returns nil. Otherwise it returns t.
+
.SS Functions max and min
.TP