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 mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 9DA3ABBAF for ; Wed, 21 Apr 2010 23:31:59 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApgBAO0Lz0tCbwQakGdsb2JhbACcGhUBAQEBCQkMBxEEHr4ZBYUOgzg X-IronPort-AV: E=Sophos;i="4.52,252,1270418400"; d="scan'208";a="57451275" Received: from out2.smtp.messagingengine.com ([66.111.4.26]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/ADH-AES256-SHA; 21 Apr 2010 23:31:58 +0200 Received: from compute2.internal (compute2.internal [10.202.2.42]) by gateway1.messagingengine.com (Postfix) with ESMTP id 7E6B0EB10E; Wed, 21 Apr 2010 17:31:57 -0400 (EDT) Received: from heartbeat2.messagingengine.com ([10.202.2.161]) by compute2.internal (MEProxy); Wed, 21 Apr 2010 17:31:57 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=messagingengine.com; h=message-id:date:from:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding; s=smtpout; bh=Vi9Q2UJHgI5Ro5UV2Nlh3Z0ltZw=; b=I7+UxtNBLrNkfqwjdpQ612yPwXhZKcPaSLVxlsstTegLZ+pGe9VOD72tADE1ynCPGdtWSC3mJR+w9imjyihlyvL73GX8GhGfZHtkBiTBQGd+T+9Y8EQhXinwoqvW4blvHax+SiFWvWnLpNVCVtzcca+E++y1UDtjSs1bYGqBXTs= X-Sasl-enc: wa6n5jZqJ4Wu9HfX+HmCYpSuwWPnH7HI6NEeTt/WMCvc 1271885517 Received: from [192.168.1.61] (64-71-1-162.static.wiline.com [64.71.1.162]) by mail.messagingengine.com (Postfix) with ESMTPSA id 03A294DB83; Wed, 21 Apr 2010 17:31:56 -0400 (EDT) Message-ID: <4BCF6ECB.5050107@ens-lyon.org> Date: Wed, 21 Apr 2010 14:31:55 -0700 From: Martin Jambon User-Agent: Thunderbird 2.0.0.22 (X11/20090908) MIME-Version: 1.0 To: Jacques Le Normand Cc: caml-list caml-list Subject: Re: [Caml-list] polymorphic (<) References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; ens-lyon:01 traversing:01 ocaml:01 val:01 bool:01 bool:01 pervasives:01 equality:01 polymorphic:01 wrote:01 caml-list:01 caml-list:01 int:01 jambon:01 jambon:01 Jacques Le Normand wrote: > Hello caml-list, > Why doesn't (<) check for physical equality before traversing the > structures? If I remember correctly it used to be the case in older versions of OCaml, but it changed because of the standard behavior expected from NaN float values. The comparison of a NaN value with any other float should always return false, and therefore the structural comparison of any data structure containing a NaN with itself should also return false: # let x = Some [ nan ];; val x : float list option = Some [nan] # x = x;; - : bool = false # x == x;; - : bool = true The solution to your problem is to use Pervasives.compare instead of the comparison operators: # compare x x;; - : int = 0 Martin -- http://mjambon.com/