Next: , Previous: , Up: srfi comparators   [Index]


2.38.13 Comparison syntax

The following expression types allow the convenient use of comparison procedures. They come directly from SRFI-67.

Syntax: if3 ?expr ?less ?equal ?greater

The expression ?expr is evaluated; it will typically, but not necessarily, be a call on a comparison procedure.

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
Syntax: if=? ?expr ?consequent
Syntax: if=? ?expr ?consequent ?alternate
Syntax: if<? ?expr ?consequent
Syntax: if<? ?expr ?consequent ?alternate
Syntax: if>? ?expr ?consequent
Syntax: if>? ?expr ?consequent ?alternate
Syntax: if<=? ?expr ?consequent
Syntax: if<=? ?expr ?consequent ?alternate
Syntax: if>=? ?expr ?consequent
Syntax: if>=? ?expr ?consequent ?alternate
Syntax: if-not=? ?expr ?consequent
Syntax: if-not=? ?expr ?consequent ?alternate

The expression ?expr is evaluated; it will typically, but not necessarily, be a call on a comparison procedure.

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: , Previous: , Up: srfi comparators   [Index]