[r6rs-discuss] On the arity of comparators
Ray Dillinger
bear at sonic.net
Mon Oct 20 14:00:23 EDT 2008
On Mon, 2008-10-20 at 10:34 -0700, Ray Dillinger wrote:
> ;; be wary of bugs in this code; I am typing it from memory
> ;; and have not tested it.
> (define gencomp? (lambda (paircomp?)
> (define comp? (lambda arglist
> (cond ((empty-list? arglist) #t)
> ((empty-list? (cdr arglist) #t)
> ((paircomp? (car arglist) (cadr arglist))
> (comp? (cdr arglist)))
> (else #f))))))
Sigh. That'll teach me to trust my memory. I shoulda wrote:
;; be wary of bugs in this code; I am typing it from memory
;; and have not tested it.
(define gencomp? (lambda (paircomp?)
(define comp? (lambda arglist
(cond ((empty-list? arglist) #t)
((empty-list? (cdr arglist) #t)
((paircomp? (car arglist) (cadr arglist))
(comp? (cdr arglist)))
(else #f))))
comp?))
allows definition of all general comparisons as a function of the
corresponding pairwise comparisons.
Bear
More information about the r6rs-discuss
mailing list