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 5B900BBAF for ; Sat, 2 Oct 2010 18:09:46 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjoCAPr1pkzRVda2kGdsb2JhbACDHp8YCBUBAQEBCQkMBxEDH6cBiQiIdIhlgSKDLnQEijyFZQ X-IronPort-AV: E=Sophos;i="4.57,271,1283724000"; d="scan'208";a="76272567" Received: from mail-iw0-f182.google.com ([209.85.214.182]) by mail1-smtp-roc.national.inria.fr with ESMTP; 02 Oct 2010 18:09:45 +0200 Received: by iwn10 with SMTP id 10so183575iwn.27 for ; Sat, 02 Oct 2010 09:09:45 -0700 (PDT) Received: by 10.231.169.149 with SMTP id z21mr7492316iby.11.1286035778014; Sat, 02 Oct 2010 09:09:38 -0700 (PDT) MIME-Version: 1.0 Sender: hcarty@mulethief.com Received: by 10.231.171.203 with HTTP; Sat, 2 Oct 2010 09:09:17 -0700 (PDT) In-Reply-To: References: <1286029361.2168.47.camel@io> From: "Hezekiah M. Carty" Date: Sat, 2 Oct 2010 12:09:17 -0400 X-Google-Sender-Auth: -vx_vCWSa77-9Jbd2LxcrL7mj4w Message-ID: Subject: Re: [Caml-list] from if...else to pattern matching To: ben kuin Cc: Philip , caml-list@inria.fr Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam: no; 0.00; val:01 bool:01 beginner's:01 wrote:01 matched:01 caml-list:01 int:01 defined:02 match:02 seems:03 let:03 let:03 pattern:04 anyway:05 matching:05 On Sat, Oct 2, 2010 at 10:47 AM, ben kuin wrote: >> >> # let t x =3D match x with >> =C2=A0a when x<=3D4 -> true >> =C2=A0| _ -> false;; >> > > ok, I had a similar attempt with > > =C2=A0 =C2=A0let tt x =3D function > =C2=A0 =C2=A0a when x<=3D4 -> true > =C2=A0 =C2=A0| _ -> false;; > > but that gave me the following (scary =C2=A0-> 'a -> ) signature > > =C2=A0 =C2=A0 val tt : int -> 'a -> bool =3D > > so I stopped > > thanks anyway > This seems to be a common beginner mistake (hence the reference to the beginner's list). You defined tt as a function which takes two arguments, x and another matched by "function" - which tt ignores the value of (a when x <=3D 4). The pattern-matched value is never used, therefore it can be any type. Hope this helps, Hez