[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Numerical Comparison: "required coercions"
Date: Thu, 26 Mar 87 13:34 EST
From: Michael Greenwald <Greenwald@STONY-BROOK.SCRC.Symbolics.COM>
Date: Thu, 26 Mar 87 10:47 EST
From: David C. Plummer <DCP@QUABBIN.SCRC.Symbolics.COM>
Date: Thu, 26 Mar 87 10:29 EST
From: Guy Steele <gls@Think.COM>
This issue makes me want to restate an earlier proposed model
for the comparison functions:
(? x1 x2 x3 x4 ... xn-1 xn) <=>
(AND (? x1 x2) (? x1 x3) (? x1 x4) ... (? x1 xn-1) (? x1 xn)
(? x2 x3) (? x2 x4) ... (? x2 xn-1) (? x2 xn)
(? x3 x4) ... (? x3 xn-1) (? x3 xn)
. .
. .
.
(? xn-1 xn))
where "?" may be =, /=, <, >, <=, or >=.
That is, in principle every pair of arguments is compared.
This is the model that justifies the "all different" interpretation for /=,
and it is recognized that in practice the other five operations may
be implemented cleverly through exploitation of transitivity. Well,
maybe such reliance on transitivity is wrong.
Why "maybe"? (<= 1234d10 12340000000001 1234e10 12340000000000) => T
when you depend on transitivity, but should => NIL according to the
above model.
On the other hand, SORT clearly depends on transitivity, and one might
reasonably expect (APPLY '<= (SORT SEQUENCE '<=)) => T.
(Or even more reasonably (APPLY '< (SORT SEQUENCE '<)) => T, which
unfortunately isn't true since
(SORT '(1234d10 12340000000001 1234e10 12340000000000) '<) returns the
original sequence.)
I was wrong. The < case isn't a reasonable expectation. Mike McMahon
points out: (APPLY '< (SORT '(1 1 1 1 1 1 1) '<)). I guess I wasn't
thinking too clearly.