[r6rs-discuss] Comparison procedures' number of arguments
David Van Horn
dvanhorn at cs.brandeis.edu
Fri Oct 24 14:03:25 EDT 2008
Alan Watson wrote:
>> I bet similarly you cannot find any
>> occurrences of (+) or (+ n).
>
> I don't think (+) has much relevance to a discussion of (<), because
> addition is a common reduction operation, and one wants (+ (reduce +
> list0) (reduce + list1)) to be the same as (reduce + (append list0
> list1)) regardless of whether list0 or list1 are null lists.
My point is not so much that (<) is useful or not useful, but rather
that the number of source code occurrences of (<) is a poor metric for
its usefulness.
I think we all agree + being defined on 0 or more arguments is useful,
yet where will find a syntactic occurrence of (+) or (+ n)? We won't,
and why would we? You would write 0 or n instead. The point is that +
may still be applied to zero arguments as in:
(define (sum ls) (apply + ls))
(sum '())
Grep will not help you find the dynamic occurrence of (+) here.
David
PS I do think there is a case to be made for the usefulness of (<) by
appealing to similar patterns, like:
(define (sorted? ls) (apply <= ls))
Which will break as <= is currently defined. [That any empty or
singleton list is sorted, is in my view widely accepted and
uncontroversial. I'm surprised to even hear this questioned.]
More information about the r6rs-discuss
mailing list