From: John R Harrison <johnh@ichips.intel.com>
To: caml-list@inria.fr
Cc: John Harrison <johnh@ichips.intel.com>
Subject: Re: polymorphic equality and overloading
Date: Wed, 05 Jul 2000 15:40:28 -0700 [thread overview]
Message-ID: <200007052240.PAA21974@dtthp127.pdx.intel.com> (raw)
Eijiro Sumii writes:
| But as you know (and as I wrote in my previous messages), the
| polymorphic equality in Caml is not at all the "equality in
| mathematics" for many (or most?) datatypes.
Probably "most" is an exaggeration. But there are quite a few examples.
One I haven't seen mentioned in this thread is the type of floating point
numbers. The equality relation defined in the main standard for binary
floating point arithmetic (IEEE 754) is not reflexive. Specifically x = x
is false if x is a NaN ("not a number"). So again, this is really an
instance of overloading in CAML:
#let x = 0.0 /. 0.0;;
x : float = nan.0
#x = x;;
- : bool = false
#x == x;;
- : bool = true
Nevertheless, I find the CAML polymorphic equality and orderings pretty
useful and superficially simple, even if they sometimes have a touch of
arbitrariness about them.
Is it possible using just equality, not orderings, to write a set-compare
operation on polymorphic lists using fewer than 0(n^2) operations?
Trivially, using orderings, one can just sort both lists in O(n log n)
operations then run along them in order. Is there something comparably
efficient just using equality?
John.
next reply other threads:[~2000-07-07 14:29 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-07-05 22:40 John R Harrison [this message]
-- strict thread matches above, loose matches on Subject: below --
2000-06-29 21:10 Eijiro Sumii
2000-06-30 17:08 ` Brian Rogoff
2000-06-30 17:51 ` Eijiro Sumii
2000-07-04 7:09 ` Jacques Garrigue
2000-07-04 12:42 ` Eijiro Sumii
2000-07-05 1:11 ` Jacques Garrigue
2000-07-05 2:37 ` Eijiro Sumii
2000-07-05 21:22 ` Pierre Weis
2000-07-05 21:30 ` Eijiro Sumii
2000-07-05 22:15 ` Pierre Weis
2000-07-05 23:09 ` Eijiro Sumii
2000-07-06 17:18 ` Benjamin Werner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200007052240.PAA21974@dtthp127.pdx.intel.com \
--to=johnh@ichips.intel.com \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox