Browse thread
Annoying behaviour of OCaml
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Oliver Bandel <oliver@f...> |
| Subject: | Re: [Caml-list] Annoying behaviour of OCaml |
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