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 19CA2BB84 for ; Tue, 9 May 2006 15:16:16 +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 k49DGFuY027089 for ; Tue, 9 May 2006 15:16:15 +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 PAA29924 for ; Tue, 9 May 2006 15:16:15 +0200 (MET DST) Received: from py-out-1112.google.com (py-out-1112.google.com [64.233.166.176]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k49DGEx4008677 for ; Tue, 9 May 2006 15:16:14 +0200 Received: by py-out-1112.google.com with SMTP id c59so1750648pyc for ; Tue, 09 May 2006 06:16:14 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=NE2veR/zZm6Yu8GoiLEWIBHJnkumiNtIR2wpaX8loVYPKZabW9TF8bd+/Xaok9WhnxveXHMlzDaZWOIgLS2we1kNlQU9QpotMVBxE2P5UGmjq+TJwqzWYU7CKDpKwE2pSjCpJQk6pW9XAW1P80r4Osge6AoIlYNLzCZdq0M7w2g= Received: by 10.35.107.20 with SMTP id j20mr2359384pym; Tue, 09 May 2006 06:16:14 -0700 (PDT) Received: by 10.35.27.19 with HTTP; Tue, 9 May 2006 06:16:14 -0700 (PDT) Message-ID: <6b8a91420605090616s5363b38bv40d72919044dfe7@mail.gmail.com> Date: Tue, 9 May 2006 15:16:14 +0200 From: "Remi Vanicat" To: "Christophe Raffalli" Subject: Re: [Caml-list] is this a bug ? Cc: caml-list In-Reply-To: <44609473.6030004@univ-savoie.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <44609473.6030004@univ-savoie.fr> X-j-chkmail-Score: MSGID : 4460961E.000 on nez-perce : j-chkmail score : X : 0/20 1 X-Miltered: at concorde with ID 4460961F.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 4460961E.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; bug:01 christophe:01 raffalli:01 christophe:01 raffalli:01 univ-savoie:01 2006:98 wrote:01 wrote:01 caml-list:01 matched:01 remi:01 remi:01 int:01 int: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=RCVD_BY_IP autolearn=disabled version=3.0.3 2006/5/9, Christophe Raffalli : > > hello, > > -------------------------------- > let f b l =3D match l with > [] | [_] -> 1 > | [a;_] | [_;a] when a =3D b-> 2 > | _ -> 3 > > let _ =3D > 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 =3D 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 =3D b or c =3D b -> 2 > and print "23" instead of "22" ? It is the same problem there. Only the first patttern to match is matched.