Next: srfi comparators ternary, Previous: srfi comparators syntax, Up: srfi comparators [Index]
These procedures are analogous to the number, character, and string
comparison predicates of Scheme. They allow the convenient use of
comparators in situations where the expression types are not usable.
They are also analogous to the similarly named procedures of
SRFI-67, but handle arbitrary numbers of arguments, which in
SRFI-67 requires the use of the variants whose names begin with
chain
.
These procedures apply the comparison procedure of comparator to
the objects as follows: if the specified relation returns #t
for
all objj and objk where 1 <= j < k <= N and N
is the number of objects, then the procedures return #t
; otherwise
return #f
.
The order in which the values are compared is unspecified. Because the relations are transitive, it suffices to compare each object with its successor.
Usage examples:
(import (vicare) (srfi :114)) (define-constant C fixnum-comparator) ;;; (=? C 1 1) ⇒ #t (=? C 1 2) ⇒ #f (=? C 2 1) ⇒ #f (=? C 1 1 1) ⇒ #t (=? C 1 2 3) ⇒ #f (=? C 2 1 3) ⇒ #f (=? C 3 2 1) ⇒ #f (=? C 1 3 2) ⇒ #f ;;; (<? C 1 1) ⇒ #f (<? C 1 2) ⇒ #t (<? C 2 1) ⇒ #f (<? C 1 1 1) ⇒ #f (<? C 1 2 3) ⇒ #t (<? C 2 1 3) ⇒ #f (<? C 3 2 1) ⇒ #f (<? C 1 3 2) ⇒ #f ;;; (>? C 1 1) ⇒ #f (>? C 1 2) ⇒ #f (>? C 2 1) ⇒ #t (>? C 1 1 1) ⇒ #f (>? C 3 2 1) ⇒ #t (>? C 1 2 3) ⇒ #f (>? C 2 1 3) ⇒ #f (>? C 1 3 2) ⇒ #f ;;; (<=? C 1 1) ⇒ #t (<=? C 1 2) ⇒ #t (<=? C 2 1) ⇒ #f (<=? C 1 1 1) ⇒ #t (<=? C 1 2 3) ⇒ #t (<=? C 2 1 3) ⇒ #f (<=? C 3 2 1) ⇒ #f (<=? C 1 3 2) ⇒ #f ;;; (>=? C 1 1) ⇒ #t (>=? C 1 2) ⇒ #f (>=? C 2 1) ⇒ #t (>=? C 1 1 1) ⇒ #t (>=? C 3 2 1) ⇒ #t (>=? C 1 2 3) ⇒ #f (>=? C 2 1 3) ⇒ #f (>=? C 1 3 2) ⇒ #f
These procedures return predicates which, when applied to two or more
arguments, return #t
if comparing the arguments using the equality
or comparison procedures of comparator shows that the objects bear
the specified relation to one another. Such predicates can be used in
contexts that do not understand or expect comparators.
Usage examples:
(import (vicare) (srfi :114)) (define-constant C fixnum-comparator) ;;; (let ((fun=? (make= C))) (fun=? 1 1) ⇒ #t (fun=? 1 2) ⇒ #f (fun=? 2 1) ⇒ #f (fun=? 1 1 1) ⇒ #t (fun=? 1 2 3) ⇒ #f (fun=? 2 1 3) ⇒ #f (fun=? 3 2 1) ⇒ #f (fun=? 1 3 2)) ⇒ #f ;;; (let ((fun<? (make< C))) (fun<? 1 1) ⇒ #f (fun<? 1 2) ⇒ #t (fun<? 2 1) ⇒ #f (fun<? 1 1 1) ⇒ #f (fun<? 1 2 3) ⇒ #t (fun<? 2 1 3) ⇒ #f (fun<? 3 2 1) ⇒ #f (fun<? 1 3 2)) ⇒ #f ;;; (let ((fun>? (make> C))) (fun>? 1 1) ⇒ #f (fun>? 1 2) ⇒ #f (fun>? 2 1) ⇒ #t (fun>? 1 1 1) ⇒ #f (fun>? 3 2 1) ⇒ #t (fun>? 1 2 3) ⇒ #f (fun>? 2 1 3) ⇒ #f (fun>? 1 3 2)) ⇒ #f ;;; (let ((fun<=? (make<= C))) (fun<=? 1 1) ⇒ #t (fun<=? 1 2) ⇒ #t (fun<=? 2 1) ⇒ #f (fun<=? 1 1 1) ⇒ #t (fun<=? 1 2 3) ⇒ #t (fun<=? 2 1 3) ⇒ #f (fun<=? 3 2 1) ⇒ #f (fun<=? 1 3 2)) ⇒ #f ;;; (let ((fun>=? (make>= C))) (fun>=? 1 1) ⇒ #t (fun>=? 1 2) ⇒ #f (fun>=? 2 1) ⇒ #t (fun>=? 1 1 1) ⇒ #t (fun>=? 3 2 1) ⇒ #t (fun>=? 1 2 3) ⇒ #f (fun>=? 2 1 3) ⇒ #f (fun>=? 1 3 2)) ⇒ #f
Next: srfi comparators ternary, Previous: srfi comparators syntax, Up: srfi comparators [Index]