44.1 Comparisons of Booleans

bool1 = bool2, bool1 < bool2

The equality operator = evaluates to true if the two boolean values bool1 and bool2 are equal, i.e., both are true or both are false, and false otherwise. The inequality operator < evaluates to true if the two boolean values bool1 and bool2 are different and false otherwise. This operation is also called the exclusive or, because its value is true if exactly one of bool1 or bool2 is true.

You can compare boolean values with objects of other types. Of course they are never equal.

    gap> true = false;
    false
    gap> false = (true = false);
    true
    gap> true <> 17;
    true 

bool1 < bool2, bool1 <= bool2,
bool1 bool2, bool1 = bool2

The operators <, <=, , and = evaluate to true if the boolean value bool1 is less than, less than or equal to, greater than, and greater than or equal to the boolean value bool2. The ordering of boolean values is defined by true < false.

You can compare boolean values with objects of other types. Integers, rationals, cyclotomics, permutations, and words are smaller than boolean values. Objects of the other types, i.e., functions, lists, and records are larger.

    gap> true < false;
    true
    gap> false >= true;
    true
    gap> 17 < true;
    true
    gap> true < [17];
    true 

Up Top Next
Index

GAP 3.4.4
April 1997