Previous: , Up: syslib   [Index]


12.26 Comparison procedures

The library (vicare system comparison-procedures) defines comparison procedures or the core object–types. When applied to two values A and B of the same type, a comparison procedure returns a fixnum:

-1

If A is less than B.

0

If A is equal to B.

+1

If A is greater than B.

The following syntactic binding are exported by the library (vicare system comparison-procedures).

Function: make-comparison-procedure type-pred equal-to less-than

Build and return a comparison procedure using the equality predicate equal-to and the “less than” predicate less-than. The arguments of the comparison procedures are validated using the type predicate type-pred.

(define compar-fx
  (make-comparison-procedure fixnum? fx=? fx<?))

(compar-fx -1 +1)       ⇒ -1
(compar-fx +1 +1)       ⇒  0
(compar-fx +1 -1)       ⇒ +1