Next: comparisons sequence, Previous: comparisons conventions, Up: comparisons [Index]
This section describes comparison procedures for most of the atomic types of R6RS: booleans, characters, strings, symbols, and numbers. As a general naming convention, a procedure named:
type-compare-order
compares two objects of the type type with respect to a total order for which order is a mnemonic hint (e.g. ‘-ci’ for case–insensitive). Of course, ‘-order’ may be absent if there is just one order or the order is obvious. It is an error if a comparison procedure accepting objects of a certain type is called with one or two arguments not of that type.
Compare two booleans, ordered by #f < #t.  A non–false value
is not interpreted as a “true value,” but rather an error will be
signalled.
Compare characters as char<=? and char-ci<=?
respectively.  The suffix -ci means “case insensitive.”
Compare strings as string<= and string-ci<=?.  The suffix
-ci means “case insensitive.”
Compares symbols as string<= on the names returned by
symbol->string.
Compare two numbers using the R6RS functions = and <.
It is an error if an argument is not of the type specified by the name
of the procedure.
Complex numbers are ordered based on their magnitude:
(real-compare (magnitude x) (magnitude y))
If at least one among x and y is a complex number:
number-compare defaults to complex-compare, else it
defaults to real-compare.
If one or both the arguments is ‘+nan.0’:
integer-comparerational-compareRaise an error because ‘+nan.0’ is neither integer nor rational.
real-comparecomplex-comparenumber-compareReturn ‘+nan.0’.
Next: comparisons sequence, Previous: comparisons conventions, Up: comparisons [Index]