diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2016-11-01 20:55:46 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2016-11-01 20:55:46 -0700 |
commit | d01a12405fbffb6a68345f72a510bf9e25e8ef95 (patch) | |
tree | e6467491e22d3ebbd1e8289b34a64dda5fbd7653 | |
parent | c038597853327f81ef1fc51584500a0073a9833e (diff) | |
download | txr-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.c | 3 | ||||
-rw-r--r-- | lib.h | 4 | ||||
-rw-r--r-- | txr.1 | 48 |
3 files changed, 54 insertions, 1 deletions
@@ -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)); @@ -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) @@ -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 ) |