3.2. Booleans Operators |

Expressions in Lush are considered ``false'' when their evaluation returns the empty list. All other expressions are considered ``true''. The symbol

3.2.0. Boolean Arithmetic |

A number of functions are available for programming tests and to return boolean values

3.2.0.0. (= n1 n2) |
[DX] |

Test if

This function supports any Lush object.

- It is able to compare
the values of numbers, strings, dates, lists, matrices, arrays, hash
tables and high level objects (those created by
**new**and belonging to classes created by**defclass**).

- The comparison of other low-level objects (i.e. from user defined
classes written in C language following the Open protocol) usually
relies upon physical equality. However, it is possible to put other
comparison functions into the C structures which define the classes.

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] |

Tests if

(de <> (n1 n2) (not (= n1 n2)))

Example:

? (<> 2 "abcd") = t

? (<> 2 2) = ()See: (=

3.2.0.2. (== n1 n2) |
[DX] |

See: (=

Test if

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:

- Physically changing list component using
**rplaca**or**rplacd**.

- Setting the contents of an array or a matrix.

- Setting the value of a slot of an object

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] |

Test if

See: Special Numerical Values (IEEE754).

3.2.0.4. (0<> n) |
[DX] |

Test if

See: Special Numerical Values (IEEE754).

3.2.0.5. (<= n1 n2) |
[DX] |

Test if

See: Special Numerical Values (IEEE754).

See: Comparison of User Defined Objects.

3.2.0.6. (< n1 n2) |
[DX] |

Test if

See: Special Numerical Values (IEEE754).

See: Comparison of User Defined Objects.

3.2.0.7. (>= n1 n2) |
[DX] |

Test if

See: Special Numerical Values (IEEE754).

See: Comparison of User Defined Objects.

3.2.0.8. (> n1 n2) |
[DX] |

Test if

See: Special Numerical Values (IEEE754).

See: Comparison of User Defined Objects.

3.2.0.9. (and l1 ... ln) |
[DX] |

Evaluates sequentially

Example:

? (and (= 2 2) (= 2 3) (print (= 2 2))) = ()

3.2.0.10. (or l1 ... ln) |
[DX] |

Evaluates sequentially

Example:

? (or (= 2 2) (= 2 3)) = t

3.2.0.11. (null l) |
[DX] |

Returns

Example:

? (null t) = ()

3.2.0.12. (not l) |
[DX] |

The

3.2.0.13. ~ l |
[MCHAR] (sysenv.lsh) |

This macro-character expand to

3.2.1. Predicates |

Predicates test the type of any lisp object.

3.2.1.0. (listp l) |
[DX] |

Returns a non-nil result when

Example:

? (listp ()) = t

? (listp "abc") = ()

? (listp '(2 3)) = (2 3)

3.2.1.1. (consp l) |
[DX] |

Returns a non-nil result when

Example:

? (consp ()) = ()

? (consp "abc") = ()

? (consp '(2 3)) = (2 3)

3.2.1.2. (atomp l) |
[DX] |

Returns a non-nil result when

Example:

? (atomp ()) = t

3.2.1.3. (numberp l) |
[DX] |

Returns a non-nil result when

Example:

? (numberp 3.14) = 3.14

3.2.1.4. (symbolp l) |
[DX] |

Returns a non-nil when

Example:

? (symbolp 'a) = a

3.2.1.5. (externp l) |
[DX] |

Returns a non-nil result item when

Example:

? (externp car) = ::DX:car

3.2.1.6. (classp l) |
[DE] |

Returns a non-nil item when

Example:

? (classp object) = t

3.2.1.7. (functionp n) |
[DX] |

Returns

Example:

? (functionp "abc") = ()

? (functionp functionp) = ::DX:functionp

3.2.1.8. (stringp s) |
[DX] |

Returns a non nil result if

Example:

? (stringp "abc") = "abc"