From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 2F64B7F75C for ; Wed, 10 Sep 2014 14:41:04 +0200 (CEST) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of pip88nl@gmail.com) identity=pra; client-ip=74.125.82.177; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="pip88nl@gmail.com"; x-sender="pip88nl@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of pip88nl@gmail.com designates 74.125.82.177 as permitted sender) identity=mailfrom; client-ip=74.125.82.177; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="pip88nl@gmail.com"; x-sender="pip88nl@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-we0-f177.google.com) identity=helo; client-ip=74.125.82.177; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="pip88nl@gmail.com"; x-sender="postmaster@mail-we0-f177.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AnsFAJ5FEFRKfVKxm2dsb2JhbABZgmqBTbEUCwadMYMtAYEOFhABAQEBAQYLCwkUKoQEAQEEEi4BGx4DDAYFGAklDwUPEQEFAVeICwEDEQEEnC9rjR0FgxCJDwoZJw1mhVMBEQEFDoVuiVgWgxmBHQWccpM9QYMaHIFda4JPAQEB X-IPAS-Result: AnsFAJ5FEFRKfVKxm2dsb2JhbABZgmqBTbEUCwadMYMtAYEOFhABAQEBAQYLCwkUKoQEAQEEEi4BGx4DDAYFGAklDwUPEQEFAVeICwEDEQEEnC9rjR0FgxCJDwoZJw1mhVMBEQEFDoVuiVgWgxmBHQWccpM9QYMaHIFda4JPAQEB X-IronPort-AV: E=Sophos;i="5.04,499,1406584800"; d="asc'?scan'208";a="78440963" Received: from mail-we0-f177.google.com ([74.125.82.177]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 10 Sep 2014 14:41:03 +0200 Received: by mail-we0-f177.google.com with SMTP id u57so4814235wes.22 for ; Wed, 10 Sep 2014 05:41:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=6Q0htOkUooz7WPM+C3NOREq4FPRXe6bfDWE4IHnE+z8=; b=LCmobz2/orxbzN9UQpLXNnzSlHZDPZIq8BEuDuSmStHXFDT2bQ5rftY6Loa+Ce94Qk 0lTwm3+DC1jvbgb1QjhhonY9jdbrXnWp1REQ8J1UFreJ8pwPDaT5h7iuNNldBDAizbuB rOW2sKev/dOzwTswfi2Fx9ADN3logCM5yyUqdYgWpI/BQga7xgztTkl0TnSHqBQY1sv5 1GX1O0QmayokeOYc5THY7CfdOBf9EL9zwb/4an/DC7/TeoQ47tySBoANkK7wkwq2aN8g BXS/2jtdumQ6m21vE8VZPtF2FyZa1of0CZYnt/hdAwnMZS/yH97A0Wm3trX1Vd3zv/mT yGNQ== X-Received: by 10.180.188.141 with SMTP id ga13mr36018363wic.18.1410352863450; Wed, 10 Sep 2014 05:41:03 -0700 (PDT) Received: from localhost (xinutec.org. [2001:41d0:2:91b4::1]) by mx.google.com with ESMTPSA id xs2sm1255462wjb.25.2014.09.10.05.41.02 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 10 Sep 2014 05:41:02 -0700 (PDT) Date: Wed, 10 Sep 2014 13:41:01 +0100 From: Pippijn van Steenhoven To: caml-list@inria.fr Message-ID: <20140910124101.GA30231@xinutec.org> References: <54101221.3010304@users.sourceforge.net> <1410348425.3003.11.camel@thinkpad> <1410351988.3003.19.camel@thinkpad> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="Qxx1br4bt0+wmkIi" Content-Disposition: inline In-Reply-To: <1410351988.3003.19.camel@thinkpad> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [Caml-list] Clarification for the configuration of comparison functions --Qxx1br4bt0+wmkIi Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Sep 10, 2014 at 02:26:28PM +0200, Gerd Stolpmann wrote: > type t =3D ... > type t_cmp =3D t * int >=20 > let wrap x =3D (x, Hashtbl.hash x) >=20 > let my_compare (x1,h1) (x2,h2) =3D > if h1=3Dh2 then > compare x1 x2 > else > h1-h2 This code is incorrect when h1 is large and negative. You should use "compare h1 h2" and annotate h1 and/or h2 with its type (int), so that int-compare is called directly. Also, if you store the hash before the actual value, compare will probably stop comparing after it finds that the hashes are not equal, so you can simply use the polymorphic compare on t_cmp. I don't know this for sure, since I haven't looked at the source, but I would assume this is true. --=20 Pippijn --Qxx1br4bt0+wmkIi Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEARECAAYFAlQQRt0ACgkQJc+zqGNdDgpmCwCfUgrGdHUXiQu7Q3XCSJkWI9YM 9/oAnjOGX+ROfpyReSb3Y4uLszhMtPz6 =BYoA -----END PGP SIGNATURE----- --Qxx1br4bt0+wmkIi--