Next: comparisons pred, Previous: comparisons cons, Up: comparisons [Index]
The facilities described in this section provide a mechanism for using a compare procedure (passed as a parameter) in the different situations arising in applications.
?c, ?less, ?equal, and ?greater are expressions.
if3
is the 3–way conditional for comparisons. First ?c is
evaluated, resulting in value c. The value c must be an
exact integer in {-1, 0, 1}
, otherwise an error is signalled.
The value of the if3
expression is obtained by evaluating
?less.
?equal is evaluated.
?greater is evaluated.
?c, ?consequent, and ?alternate are expressions. If
?alternate is not provided, (if #f #f)
is used.
These six macros are 2–way conditionals for comparisons. First ?c is evaluated, resulting in value c. The value c must be an exact integer in {-1, 0, 1}, otherwise an error is signalled. Then, depending on the value of c and the name of the macro, either ?consequence or ?alternate is evaluated, and the resulting value is the value of the conditional expression.
The branch is chosen according to the following table:
?consequent | ?alternate | |
---|---|---|
if=? | c = 0 | c in {-1, 1} |
if<? | c = -1 | c in {0, 1} |
if>? | c = 1 | c in {-1, 0} |
if<=? | c in {-1, 0} | c = 1 |
if>=? | c in {0, 1} | c = -1 |
if-not=? | c in {-1, 1} | c = 0 |
Next: comparisons pred, Previous: comparisons cons, Up: comparisons [Index]