Next: srfi comparators compar pred, Previous: srfi comparators compar proc, Up: srfi comparators [Index]
The following expression types allow the convenient use of comparison procedures. They come directly from SRFI-67.
The expression ?expr is evaluated; it will typically, but not necessarily, be a call on a comparison procedure.
-1
: ?less is evaluated and its values are
returned.
0
: ?equal is evaluated and its values
are returned.
+1
: ?greater is evaluated and its values
are returned.
Usage examples:
#!vicare (import (vicare) (srfi :114)) (if3 (compare 1 1) 'less 'equal 'greater) ⇒ equal (if3 (compare 1 2) 'less 'equal 'greater) ⇒ less (if3 (compare 2 1) 'less 'equal 'greater) ⇒ greater
The expression ?expr is evaluated; it will typically, but not necessarily, be a call on a comparison procedure.
-1
,
0
, or +1
.
Usage examples:
#!vicare (import (vicare) (srfi :114)) (if=? (compare 1 1) #t #f) ⇒ #t (if=? (compare 1 2) #t #f) ⇒ #f (if=? (compare 2 1) #t #f) ⇒ #f (if=? (compare 1 1) #t) ⇒ #t (if=? (compare 1 2) #t) ⇒ #<void> (if=? (compare 2 1) #t) ⇒ #<void> ;;; (if-not=? (compare 1 1) #f #t) ⇒ #t (if-not=? (compare 1 2) #f #t) ⇒ #f (if-not=? (compare 2 1) #f #t) ⇒ #f (if-not=? (compare 1 1) #t) ⇒ #<void> (if-not=? (compare 1 2) #t) ⇒ #t (if-not=? (compare 2 1) #t) ⇒ #t ;;; (if<? (compare 1 1) #t #f) ⇒ #f (if<? (compare 1 2) #t #f) ⇒ #t (if<? (compare 2 1) #t #f) ⇒ #f (if<? (compare 1 1) #t) ⇒ #<void> (if<? (compare 1 2) #t) ⇒ #t (if<? (compare 2 1) #t) ⇒ #<void> ;;; (if>? (compare 1 1) #t #f) ⇒ #f (if>? (compare 1 2) #t #f) ⇒ #f (if>? (compare 2 1) #t #f) ⇒ #t (if>? (compare 1 1) #t) ⇒ #<void> (if>? (compare 1 2) #t) ⇒ #<void> (if>? (compare 2 1) #t) ⇒ #t ;;; (if<=? (compare 1 1) #t #f) ⇒ #t (if<=? (compare 1 2) #t #f) ⇒ #t (if<=? (compare 2 1) #t #f) ⇒ #f (if<=? (compare 1 1) #t) ⇒ #t (if<=? (compare 1 2) #t) ⇒ #t (if<=? (compare 2 1) #t) ⇒ #<void> ;;; (if>=? (compare 1 1) #t #f) ⇒ #t (if>=? (compare 1 2) #t #f) ⇒ #f (if>=? (compare 2 1) #t #f) ⇒ #t (if>=? (compare 1 1) #t) ⇒ #t (if>=? (compare 1 2) #t) ⇒ #<void> (if>=? (compare 2 1) #t) ⇒ #t
Next: srfi comparators compar pred, Previous: srfi comparators compar proc, Up: srfi comparators [Index]