From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id A9684BB9C for ; Thu, 24 Nov 2005 16:33:47 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id jAOFXkIC021785 for ; Thu, 24 Nov 2005 16:33:47 +0100 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id QAA25364 for ; Thu, 24 Nov 2005 16:33:46 +0100 (MET) Received: from ext.lri.fr (ext.lri.fr [129.175.15.4]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id jAOFXkQ6020207 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 24 Nov 2005 16:33:46 +0100 Received: from localhost (localhost.localdomain [127.0.0.1]) by ext.lri.fr (Postfix) with ESMTP id 0FF5D202514; Thu, 24 Nov 2005 16:33:46 +0100 (CET) Received: from ext.lri.fr ([127.0.0.1]) by localhost (ext.lri.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 18409-08; Thu, 24 Nov 2005 16:33:46 +0100 (CET) Received: from smtp.lri.fr (serveur3-5 [129.175.3.5]) by ext.lri.fr (Postfix) with ESMTP id 001C02024F5; Thu, 24 Nov 2005 16:33:45 +0100 (CET) Received: from pc9-152 (pc9-152 [129.175.9.152]) by smtp.lri.fr (Postfix) with ESMTP id 32715CED98; Thu, 24 Nov 2005 16:33:45 +0100 (CET) Received: from filliatr by pc9-152 with local (Exim 3.36 #1 (Debian)) id 1EfJ6X-0008FE-00; Thu, 24 Nov 2005 16:33:45 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Message-ID: <17285.56665.713104.465830@gargle.gargle.HOWL> Date: Thu, 24 Nov 2005 16:33:45 +0100 To: Tom Hawkins Cc: caml-list@inria.fr Subject: Re: [Caml-list] Physical compare In-Reply-To: <4384C0E3.5030300@confluent.org> References: <4384C0E3.5030300@confluent.org> X-Mailer: VM 7.19 under Emacs 21.4.1 From: Jean-Christophe Filliatre X-Virus-Scanned: by amavisd-new at lri.fr X-Miltered: at concorde with ID 4385DD5B.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 4385DD5A.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 filliatre:01 filliatr:01 lri:01 integers:01 hash-consing:01 lri:01 filliatr:01 filliatre:01 wrote:01 equality:01 writes:01 short:01 define:01 precisely:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 Hello, Tom Hawkins writes: > Is their a version of "compare" that is based on physical equality? If > not, how can I define one? I tried: > > let compareq a b = if a == b then 0 else if a > b then 1 else (-1) > > But unfortunately, (>) is a structural comparison. > > I need to make a Map where the keys are distinguished by the physical > instance. Others already gave the right answer i.e. that you need to tag your values with unique integers to do that. Just to mention it, I wrote a little hash-consing library that does precisely this, together with specialized versions of Set and Map for these tagged values (based on Patricia trees). There is even a short article describing the technique. All is available on this page: http://www.lri.fr/~filliatr/software.en.html Hope this helps, -- Jean-Christophe Filliātre (http://www.lri.fr/~filliatr)