# [racket] arity of + versus <=

On Fri, Oct 28, 2011 at 10:58 AM, Stephen Bloch <sbloch at adelphi.edu> wrote:
>*
*>* OK, here's a variant of "binary->nary" that produces the results we want when "op" has contract "X X -> boolean" rather than "X X -> X"
*>*
*>* (define (binary->nary relop)
*>* (letrec ((f (lambda args
*>* (or (empty? args)
*>* (empty? (rest args))
*>* (and (relop (first args) (second args))
*>* (apply f (rest args)))))))
*>* f))
*>*
*>* This applies relop to each successive (overlapping) pair of elements and "and"s the results.
*
Yes! Thank you!
Of course this fails for n-ary add and multiply, but presumably a
person who preferred
this generalization would have to answer the dual question of the
original poster:
Why do the relational operators generalize to 0 or 1 arguments but addition and
multiplication do not?
--
~jrm