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


2.38.16 Min/max comparison procedures

Function: comparator-min comparator obj0 obj1
Function: comparator-max comparator obj0 obj1

Analogous to min and max. Apply the comparison procedure of comparator to the arguments to find and return a minimal (or maximal) object. The order in which the values are compared is unspecified.

NOTE The SRFI-67 procedures pairwise-not=? and kth-largest involve sorting their arguments, and are not provided by this proposal in order to avoid an otherwise unnecessary implementation dependency. They are easily provided by a sorting package that makes use of comparators.

Usage examples:

(import (vicare) (srfi :114))

(comparator-min C 0)           ⇒ 0
(comparator-min C 0 0)         ⇒ 0
(comparator-min C 0 1)         ⇒ 0
(comparator-min C 1 0)         ⇒ 0
(comparator-min C 0 1 2)       ⇒ 0