summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-11-01 20:55:46 -0700
committerKaz Kylheku <kaz@kylheku.com>2016-11-01 20:55:46 -0700
commitd01a12405fbffb6a68345f72a510bf9e25e8ef95 (patch)
treee6467491e22d3ebbd1e8289b34a64dda5fbd7653
parentc038597853327f81ef1fc51584500a0073a9833e (diff)
downloadtxr-d01a12405fbffb6a68345f72a510bf9e25e8ef95.tar.gz
txr-d01a12405fbffb6a68345f72a510bf9e25e8ef95.tar.bz2
txr-d01a12405fbffb6a68345f72a510bf9e25e8ef95.zip
New negated equality test functions.
* eval.c (eval_init): Register neq, neql and nequal intrinsics. * lib.h (neq, neql, nequal): New inline functions. * txr.1: Documented neq, neql and nequal
-rw-r--r--eval.c3
-rw-r--r--lib.h4
-rw-r--r--txr.148
3 files changed, 54 insertions, 1 deletions
diff --git a/eval.c b/eval.c
index 389efdf2..b1c84794 100644
--- a/eval.c
+++ b/eval.c
@@ -5043,6 +5043,9 @@ void eval_init(void)
reg_fun(eq_s, eq_f);
reg_fun(eql_s, eql_f);
reg_fun(equal_s, equal_f);
+ reg_fun(intern(lit("neq"), user_package), func_n2(neq));
+ reg_fun(intern(lit("neql"), user_package), func_n2(neql));
+ reg_fun(intern(lit("nequal"), user_package), func_n2(nequal));
reg_fun(plus_s = intern(lit("+"), user_package), func_n0v(plusv));
reg_fun(intern(lit("-"), user_package), func_n1v(minusv));
diff --git a/lib.h b/lib.h
index 50ee8640..34c6b59d 100644
--- a/lib.h
+++ b/lib.h
@@ -1017,7 +1017,9 @@ void breakpt(void);
#define nil convert(obj_t *, 0)
INLINE val eq(val a, val b) { return a == b ? t : nil; }
-
+INLINE val neq(val a, val b) { return a != b ? t : nil; }
+INLINE val neql(val left, val right) { return eql(left, right) ? nil : t; }
+INLINE val nequal(val left, val right) { return equal(left, right) ? nil : t; }
INLINE val null(val v) { return v ? nil : t; }
#define nilp(o) ((o) == nil)
diff --git a/txr.1 b/txr.1
index 47b20ac1..c6fffc4c 100644
--- a/txr.1
+++ b/txr.1
@@ -15433,6 +15433,54 @@ Certain object types have a custom
.code equal
function.
+.coNP Functions @, neq @ neql and @ nequal
+.synb
+.mets (neq < left-obj << right-obj )
+.mets (neql < left-obj << right-obj )
+.mets (nequal < left-obj << right-obj )
+.syne
+.desc
+The functions
+.codn neq ,
+.code neql
+and
+.code nequal
+are logically negated counterparts of, respectively,
+.codn eq ,
+.code eql
+and
+.codn equal .
+
+If
+.code eq
+returns
+.code t
+for a given pair of arguments
+.meta left-obj
+and
+.metn right-obj ,
+then
+.code neq
+returns
+.codn nil .
+.IR "Vice versa" ,
+if
+.code eq
+returns
+.codn nil ,
+.code neq
+returns
+.codn t .
+
+The same relationship exits between
+.code eql
+and
+.codn neql ,
+and between
+.code equal
+and
+.codn nequal .
+
.coNP Function @ less
.synb
.mets (less < left-obj << right-obj )