summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Daphne Preston-Kendal 2021-12-29 17:48:01 +0100
committerGravatar Daphne Preston-Kendal 2021-12-29 17:48:01 +0100
commit8c7d09b758bb04b07b9c89a7a46c8f89a3de651c (patch)
treea6b39248d22fef25492ca4c4aeb8cb7aca4805e0
parentit’s an SRFI (diff)
Nix compose-comparator syntax, rename composed to product comparator
-rw-r--r--composing-comparators.scm24
-rw-r--r--srfi-228.html7
2 files changed, 2 insertions, 29 deletions
diff --git a/composing-comparators.scm b/composing-comparators.scm
index c6b6c7d..3356797 100644
--- a/composing-comparators.scm
+++ b/composing-comparators.scm
@@ -16,7 +16,7 @@
((comparator-hash-function contents-comparator) x))
#f)))
-(define (make-composed-comparator type-test . comparators)
+(define (make-product-comparator type-test . comparators)
(make-comparator
type-test
(if (every comparator-equality-predicate comparators)
@@ -43,28 +43,6 @@
(list->generator comparators))))
#f)))
-(define-syntax compose-comparator
- (syntax-rules ()
- ((_ type-test (unwrap . more) ...)
- (make-composed-comparator
- type-test
- (let-values (((unwrap cmp) (compose-comparator-form unwrap . more)))
- (make-wrapper-comparator
- (comparator-type-test-predicate cmp)
- unwrap
- cmp)) ...))))
-
-(define-syntax compose-comparator-form
- ;; Using this submacro enables enforcement of the correct form with
- ;; moderately more useful syntax errors than doing it the SRFI 9
- ;; way, at least within the limited bounds of what one can do for
- ;; that in syntax-rules.
- (syntax-rules ()
- ((_ unwrap) (compose-comparator-form unwrap (make-default-comparator)))
- ((_ unwrap cmp)
- (values
- unwrap cmp))))
-
(define (comparison-procedures comparator)
(values
(lambda args (apply <? comparator args))
diff --git a/srfi-228.html b/srfi-228.html
index 6f9bf7b..f5f0eb5 100644
--- a/srfi-228.html
+++ b/srfi-228.html
@@ -46,15 +46,10 @@
<dd>
<p>Returns a comparator which compares values satisfying the predicate <var>type-test</var> by first calling the given <var>unwrap</var> procedure on them, then comparing the output of that procedure with the given <var>contents-comparator</var>. The hash function of the wrapper comparator returns the same value as the <var>contents-comparator</var> run on the unwrapped value.</p>
- <dt><code>(make-wrapper-comparator</code> <var>type-test</var> <var>comparator</var> ... <code>)</code> (Procedure)
+ <dt><code>(make-product-comparator</code> <var>type-test</var> <var>comparator</var> ... <code>)</code> (Procedure)
<dd>
<p>Returns a comparator which compares values satisfying the given predicate <covarde>type-test</var> by comparing them with each of the given comparators in turn, left to right, and returning the result of the first non-equal comparison. If all the given comparators consider two values equal, the composed comparator also considers them equal. The hash function of the composed comparator hashes together the results of all the given comparators in an implementation-defined way.</p>
- <dt><code>(compose-comparator</code> <var>type-test</var> <code>(</code><var>unwrap</var> <var>comparator</var><code>)</code> ...)</code> (Syntax)
- <dd>
- <p>Expands to a form which returns a comparator which compares values satisfying the given predicate <code>type-test</code> by running in turn, left to right, wrapper comparators made out of the given <code>unwrap</code> and <code>comparator</code>, according to the rules for <code>make-composed-comparator</code>. <code>comparator</code> may be omitted from each form, in which case the SRFI 128 default comparator is used.</p>
- <p>This is equivalent to using the procedural forms <code>make-composed-comparator</code> and <code>make-wrapper-comparator</code> together.</p>
-
<dt><code>(comparison-procedures</code> <var>comparator</var><code>)</code> (Procedure)
<dd>
<p>Returns five values, variadic procedures corresponding to <code>&lt;</code>, <code>&lt;=</code>, <code>=</code>, <code>&gt;=</code>, and <code>&gt;</code> respectively for the given comparator. Each one is equivalent to a partial application of the SRFI 128 procedures <code>&lt;?</code>, <code>&lt;=?</code>, <code>=?</code>, <code>&gt;=?</code>, and <code>&gt;?</code> with the given comparator.</p>