left-expr = right-expr
left-expr <> right-expr
The operator = tests for equality of its two operands and evaluates to
true if they are equal and to false otherwise. Likewise <> tests
for inequality of its two operands. Note that any two objects can be
compared, i.e., = and <> will never signal an error. For each type
of objects the definition of equality is given in the respective chapter.
Objects in different families (see Families) are never equal,
i.e., = evaluates in this case to false, and <> evaluates to true.
left-expr < right-expr
left-expr > right-expr
left-expr <= right-expr
left-expr >= right-expr
< denotes less than, <= less than or equal, > greater than, and
>= greater than or equal of its two operands.
For each kind of objects the definition of the ordering is given in the
respective chapter.
Only for the following kinds of objects, an ordering via < of objects
in different families (see Families) is supported.
Rationals (see IsRat) are smallest,
next are cyclotomics (see IsCyclotomic),
followed by finite field elements (see IsFFE);
finite field elements in different characteristics are compared
via their characteristics,
next are permutations (see IsPerm),
followed by the boolean values true, false, and fail
(see IsBool),
characters (such as 'a', see IsChar),
and lists (see IsList) are largest;
note that two lists can be compared with < if and only if their
elements are again objects that can be compared with <.
For other objects, GAP does not provide an ordering via <.
The reason for this is that a total ordering of all GAP objects
would be hard to maintain when new kinds of objects are introduced,
and such a total ordering is hardly used in its full generality.
However, for objects in the filters listed above, the ordering via <
has turned out to be useful.
For example, one can form sorted lists containing integers and nested
lists of integers, and then search in them using PositionSorted
(see Finding Positions in Lists).
Of course it would in principle be possible to define an ordering
via < also for certain other objects,
by installing appropriate methods for the operation \<.
But this may lead to problems at least as soon as one loads GAP code
in which the same is done, under the assumption that one is completely
free to define an ordering via < for other objects than the ones
for which the ``official'' GAP provides already an ordering via <.
Comparison operators, including the operator in
(see Membership Test for Lists),
are not associative,
Hence it is not allowed to write a = b <> c = d,
you must use (a = b) <> (c = d) instead.
(see Operations for Booleans), but lower precedence than the arithmetic
operators (see Arithmetic Operators).
Thus, for example, a * b = c and d is interpreted as
((a * b) = c) and d).
gap> 2 * 2 + 9 = Fibonacci(7); # a comparison where the left true # operand is an expression
For the underlying operations of the operators introduced above, see Comparison Operations for Elements.
[Top] [Previous] [Up] [Next] [Index]
GAP 4 manual