- debug-compare compareprocedure
Constructs a compare procedure equivalent to compare but with debugging code wrapped around the calls to compare. The debugging code signals an error if it detects a violation of the axioms of a compare function. For this it is assumed that compare has no side-effects.
More specifically, (debug-compare compare) evaluates to a compare procedure compare[1] which checks reflexivity, antisymmetry, and transitivity of compare based on the arguments on which compare[1] is called:
The procedure compare[1] checks reflexivity on any value passed to compare, antisymmetry on any pair of values on which compare is called, and transitivity on triples where two of the arguments are from the current call to compare[1] and the third is a pseudo-random selection from the two arguments of the previous call to compare[1].