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 68EA5BB84 for ; Tue, 9 May 2006 15:22:28 +0200 (CEST) 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 k49DMShA028029 for ; Tue, 9 May 2006 15:22:28 +0200 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 PAA29808 for ; Tue, 9 May 2006 15:22:27 +0200 (MET DST) Received: from net.univ-savoie.fr (net.univ-savoie.fr [193.48.120.75]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k49DMReF009710 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Tue, 9 May 2006 15:22:27 +0200 Received: from post.bourget.univ-savoie.fr (post.bourget.univ-savoie.fr [193.48.120.73]) by net.univ-savoie.fr (8.12.3/jtpda-5.4) with ESMTP id k49DMOuL024179 for ; Tue, 9 May 2006 15:22:24 +0200 Received: from [193.48.123.45] (d45.lama.univ-savoie.fr [193.48.123.45]) by post.bourget.univ-savoie.fr (8.12.3/jtpda-5.4) with ESMTP id k49DMKOM009108 ; Tue, 9 May 2006 15:22:20 +0200 Message-ID: <44609791.9090701@univ-savoie.fr> Date: Tue, 09 May 2006 15:22:25 +0200 From: Christophe Raffalli User-Agent: Mozilla Thunderbird 1.0.6-7.1.20060mdk (X11/20050322) X-Accept-Language: fr, en MIME-Version: 1.0 To: Christophe Raffalli Cc: caml-list Subject: Re: [Caml-list] is this a bug ? References: <44609473.6030004@univ-savoie.fr> In-Reply-To: <44609473.6030004@univ-savoie.fr> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.33 (www . roaringpenguin . com / mimedefang) X-Miltered: at concorde with ID 44609794.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 44609793.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; christophe:01 raffalli:01 christophe:01 raffalli:01 univ-savoie:01 bug:01 univ-savoie:01 2006:98 wrote:01 wrote:01 caml-list:01 matched:01 int:01 int:01 newline:02 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 2006/5/9, Christophe Raffalli : > > hello, > > -------------------------------- > let f b l = match l with > [] | [_] -> 1 > | [a;_] | [_;a] when a = b-> 2 > | _ -> 3 > > let _ = > print_int (f 1 [1;2]); > print_int (f 1 [2;1]); > print_newline () > -------------------------------- > > Do you think this code should have a useless pattern warning ? Yes. When you wrote a pattern as : '| [a;_] | [_;a] when a = b' it first match the pattern '| [a;_] | [_;a]' then try the condition. So it will match [a;_] and never [_;a]. You have to wrote it as : | [a;c] when a = b or c = b -> 2 > and print "23" instead of "22" ? It is the same problem there. Only the first patttern to match is matched.