Elementary Predicates
3.1 Elementary Predicates
Functions in this section return T when the condition defined is met and
NIL when it is not. Defined are type checking functions and elementary
comparisons.
ATOM(
U:
any):
boolean
eval, spread
Returns T if U is not a pair.
EXPR PROCEDURE ATOM(U);
NULL PAIRP U;
CODEP(
U:
any):
boolean
eval, spread
Returns T if U is a function-pointer.
CONSTANTP(
U:
any):
boolean eval, spread
Returns T if U is a constant (a number, string, function-pointer, or
vector).
EXPR PROCEDURE CONSTANTP(U);
NULL OR(PAIRP U, IDP U);
EQ(
U:
any,
V:
any):
boolean eval, spread
Returns T if U points to the same object as V. EQ is not a reliable
comparison between numeric arguments.
EQN(
U:
any,
V:
any):
boolean eval, spread
Returns T if U and V are EQ or if U and V are numbers and have
the same value and type.
EQUAL(
U:
any,
V:
any):
boolean eval, spread
Returns T if U and V are the same. Dotted-pairs are compared
recursively to the bottom levels of their trees. Vectors must have
identical dimensions and EQUAL values in all positions. Strings must
have identical characters. Function pointers must have EQ values.
Other atoms must be EQN equal.
FIXP(
U:
any):
boolean eval, spread
Returns T if U is an integer (a fixed number).
FLOATP(
U:
any):
boolean eval, spread
Returns T if U is a floating point number.
IDP(
U:
any):
boolean eval, spread
Returns T if U is an id.
MINUSP(
U:
any):
boolean eval, spread
Returns T if U is a number and less than 0. If U is not a number or
is a positive number, NIL is returned.
EXPR PROCEDURE MINUSP(U);
IF NUMBERP U THEN LESSP(U, 0) ELSE NIL;
NULL(
U:
any):
boolean eval, spread
Returns T if U is NIL.
EXPR PROCEDURE NULL(U);
U EQ NIL;
NUMBERP(
U:
any):
boolean eval, spread
Returns T if U is a number (integer or floating).
EXPR PROCEDURE NUMBERP(U);
IF OR(FIXP U, FLOATP U) THEN T ELSE NIL;
ONEP(
U:
any):
boolean eval, spread.
Returns T if U is a number and has
the value 1 or 1.0. Returns NIL otherwise.
a
EXPR PROCEDURE ONEP(U);
OR(EQN(U, 1), EQN(U, 1.0));
PAIRP(
U:
any):
boolean eval, spread
Returns T if U is a dotted-pair.
STRINGP(
U:
any):
boolean eval, spread
Returns T if U is a string.
VECTORP(
U:
any):
boolean eval, spread
Returns T if U is a vector.
ZEROP(
U:
any):
boolean eval, spread.
Returns T if U is a number and has the value 0 or 0.0. Returns NIL
otherwise.
a
EXPR PROCEDURE ZEROP(U);
OR(EQN(U, 0), EQN(U, 0.0));