From: Brian Hurt <bhurt@janestcapital.com>
To: Eric Cooper <ecc@cmu.edu>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Annoying behaviour of OCaml
Date: Thu, 10 Jan 2008 10:29:34 -0500 [thread overview]
Message-ID: <478639DE.6040903@janestcapital.com> (raw)
In-Reply-To: <20080110152017.GA513@stratocaster.home>
[-- Attachment #1: Type: text/plain, Size: 1050 bytes --]
Eric Cooper wrote:
>On Thu, Jan 10, 2008 at 02:52:26PM +0000, Thomas Fischbacher wrote:
>
>
>>compare [|1;2;3|] [|4;5|];; (* ...but actially is not: this gives 1,
>> supposedly because the second list is
>> shorter than the first.
>> *)
>>
>>
>
>This is indeed unexpected behavior:
> # compare "123" "45";;
> - : int = -1
> # compare [1;2;3] [4;5];;
> - : int = -1
> # compare [|1;2;3|] [|4;5|];;
> - : int = 1
>
>
>
It it? I mean, all I ever read into compare was that it returned a
*consistent* ordering- for example, if a < b and b < c, then a < c.
Note that a *specific* ordering was ever gaurenteed- and if I wanted a
specific ordering, I should implement it myself. It certainly wasn't
ever gaurenteed that the ordering would be consistent with some other
(or any other) language.
Ordering arrays based on length is an obvious performance advantage-
it's an O(1) comparison, independent of the length of the arrays (or the
cost of comparing two elements of the arrays).
Brian
[-- Attachment #2: Type: text/html, Size: 1502 bytes --]
next prev parent reply other threads:[~2008-01-10 15:29 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-10 14:52 Thomas Fischbacher
2008-01-10 15:00 ` [Caml-list] " Jean-Christophe Filliâtre
2008-01-10 15:07 ` Berke Durak
2008-01-10 15:20 ` Eric Cooper
2008-01-10 15:29 ` Brian Hurt [this message]
2008-01-10 15:47 ` Thomas Fischbacher
2008-01-10 17:33 ` Christophe Raffalli
2008-01-10 20:07 ` Oliver Bandel
2008-01-10 21:52 ` David Thomas
2008-01-10 22:29 ` Oliver Bandel
2008-01-10 22:55 ` David Thomas
2008-01-10 23:02 ` Oliver Bandel
2008-01-10 23:00 ` Oliver Bandel
2008-01-10 15:32 ` Thomas Fischbacher
2008-01-10 19:49 ` Oliver Bandel
2008-01-10 19:48 ` Oliver Bandel
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=478639DE.6040903@janestcapital.com \
--to=bhurt@janestcapital.com \
--cc=caml-list@inria.fr \
--cc=ecc@cmu.edu \
/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