Binary comparison operations have been introduced already in Comparisons. The underlying operations for which methods can be installed are the following.
\=( left-expr, right-expr ) O
\<( left-expr, right-expr ) O
Note that the comparisons via <>, <=, >, and >= are delegated to
the operations \= and \<.
In general, objects in different families cannot be compared with <.
For the reason and for exceptions from this rule, see Comparisons.
For some objects a ``normal form'' is hard to compute and thus equality of elements of a domain might be expensive to test. Therefore GAP provides a (slightly technical) property with which an algorithm can test whether an efficient equality test is available for elements of a certain kind.
CanEasilyCompareElements( obj ) P
CanEasilyCompareElementsFamily( fam ) F
CanEasilySortElements( obj ) P
CanEasilySortElementsFamily( fam ) F
CanEasilyCompareElements indicates whether the elements in the family
fam of obj can be easily compared with =.
(In some cases element comparisons are very hard, for example in cases
where no normal forms for the elements exist.)
The default method for this property is to ask the family of obj,
the default method for the family is to return false.
The ability to compare elements may depend on the successful computation
of certain information. (For example for finitely presented groups it
might depend on the knowledge of a faithful permutation representation.)
This information might change over time and thus it might not be a good
idea to store a value false too early in a family. Instead the
function CanEasilyCompareElementsFamily should be called for the
family of obj which returns false if the value of
CanEasilyCompareElements is not known for the family without computing
it. (This is in fact what the above mentioned family dispatch does.)
If a family knows ab initio that it can compare elements this property
should be set as implied filter and filter for the family (the 3rd and
4th argument of NewFamily respectively). This guarantees that code
which directly asks the family gets a right answer.
The property CanEasilySortElements and the function
CanEasilySortElementsFamily behave exactly in the same way, except
that they indicate that objects can be compared via <. This property
implies CanEasilyCompareElements, as the ordering must be total.
[Top] [Previous] [Up] [Next] [Index]
GAP 4 manual