3.2. Booleans Operators |
3.2.0. Boolean Arithmetic |
3.2.0.0. (= n1 n2) |
[DX] |
This function supports any Lush object.
Example:
? (= '(1 2 (3)) (cons 1 '(2 (3)))) = t
? (= [ 1.00 2.00 ] [ 1.00 2.00 ]) = tTesting the equality between special numeric values may be tricky. For example, the IEEE754 specification(supported by most of the industry) defines special bit patterns named NaN(Not a Number). Comparing two NaNs should always return false. Major operating systems and compilers however do not respect this.
Lush expressly specifies that the result returned by the equality test is *always* true when objects n1 and n2 share the same memory location. In other words, if the function == returns t then the function = returns t as well.
See: Special Numerical Values (IEEE754).
See: (== n1
n2 )
See: Comparison of User Defined Objects.
3.2.0.1. (<> n1 n2) |
[DX] |
(de <> (n1 n2) (not (= n1 n2)))
Example:
? (<> 2 "abcd") = t
? (<> 2 2) = ()See: (= n1 n2 )
3.2.0.2. (== n1 n2) |
[DX] |
This function does not even look at the information conveyed by the lisp objects n1 or n2 . It just tests that the pointers returned by the expression n1 and n2 are equals.
Pointer equality not only means that objects referred to by expression n1 and n2 are equal, but also means that they are located at the same memory addresses.
This information is meaningful as soon as you use functions that modify objects (as opposed to functions returning a modified copy of the object and leave the initial object unchanged). These functions include the following:
Function == may be used in conjunction with these functions. Modifying indeed the object referred to as n1 will therefore also modify the object referred to as n2 . Function == may also be used as a fast way to compare objects and matrix when you know that the only possibility of equality is physical equality.
Example:
? (setq a 3) = 3 ? (== a 3) = () ? (= a 3) = t ? (== a a) = t ? (setq a [1 2]) = [1 2] ? (setq b [1 2]) = [1 2] ? (= a b) = t ? (== a b) = () ? (a 0) = [0 2] ? (= a b) = () ? b = [1 2]
3.2.0.3. (0= n) |
[DX] |
See: Special Numerical Values (IEEE754).
3.2.0.4. (0<> n) |
[DX] |
See: Special Numerical Values (IEEE754).
3.2.0.5. (<= n1 n2) |
[DX] |
See: Special Numerical Values (IEEE754).
See: Comparison of User Defined Objects.
3.2.0.6. (< n1 n2) |
[DX] |
See: Special Numerical Values (IEEE754).
See: Comparison of User Defined Objects.
3.2.0.7. (>= n1 n2) |
[DX] |
See: Special Numerical Values (IEEE754).
See: Comparison of User Defined Objects.
3.2.0.8. (> n1 n2) |
[DX] |
See: Special Numerical Values (IEEE754).
See: Comparison of User Defined Objects.
3.2.0.9. (and l1 ... ln) |
[DX] |
Example:
? (and (= 2 2) (= 2 3) (print (= 2 2))) = ()
3.2.0.10. (or l1 ... ln) |
[DX] |
Example:
? (or (= 2 2) (= 2 3)) = t
3.2.0.11. (null l) |
[DX] |
Example:
? (null t) = ()
3.2.0.12. (not l) |
[DX] |
3.2.0.13. ~ l |
[MCHAR] (sysenv.lsh) |
3.2.1. Predicates |
3.2.1.0. (listp l) |
[DX] |
Example:
? (listp ()) = t
? (listp "abc") = ()
? (listp '(2 3)) = (2 3)
3.2.1.1. (consp l) |
[DX] |
Example:
? (consp ()) = ()
? (consp "abc") = ()
? (consp '(2 3)) = (2 3)
3.2.1.2. (atomp l) |
[DX] |
Example:
? (atomp ()) = t
3.2.1.3. (numberp l) |
[DX] |
Example:
? (numberp 3.14) = 3.14
3.2.1.4. (symbolp l) |
[DX] |
Example:
? (symbolp 'a) = a
3.2.1.5. (externp l) |
[DX] |
Example:
? (externp car) = ::DX:car
3.2.1.6. (classp l) |
[DE] |
Example:
? (classp object) = t
3.2.1.7. (functionp n) |
[DX] |
Example:
? (functionp "abc") = ()
? (functionp functionp) = ::DX:functionp
3.2.1.8. (stringp s) |
[DX] |
Example:
? (stringp "abc") = "abc"