20.2 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 or both fail, 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 = fail);
    true
    gap> true <> 17;
    true 
    

  • bool1 < bool2

    The ordering of boolean values is defined by true < false < fail. For the comparison of booleans with other GAP objects, see Section Comparisons.

    gap> true < false;  fail >= false;
    true
    true
    

    [Top] [Previous] [Up] [Next] [Index]

    GAP 4 manual
    February 2000