Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Oliver Bandel <oliver@first.in-berlin.de>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Annoying behaviour of OCaml
Date: Thu, 10 Jan 2008 20:49:31 +0100	[thread overview]
Message-ID: <1199994571.478676cb3ea26@webmail.in-berlin.de> (raw)
In-Reply-To: <20080110152017.GA513@stratocaster.home>

Zitat von Eric Cooper <ecc@cmu.edu>:

> 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

This is what I would expect.
It's the way I know.
check each char on equality.
The first comparision gives you, that "1" < "5",
and the comparison is done.



>     # compare [1;2;3] [4;5];;
>     - : int = -1
>     # compare [|1;2;3|] [|4;5|];;
>     - : int = 1

ooops?!

That's a point, where I would look into the the
documentation now ;-) because it's also unexpected for me.
Does comapre use different properties to comapare
arrays and lists?

Lists: compare element by element;
Array: comapre length?!

Ciao,
   Oliver


  parent reply	other threads:[~2008-01-10 19:49 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
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 [this message]
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=1199994571.478676cb3ea26@webmail.in-berlin.de \
    --to=oliver@first.in-berlin.de \
    --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