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 nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 8DFD3BB84 for ; Tue, 18 Apr 2006 05:25:06 +0200 (CEST) Received: from nz-out-0102.google.com (nz-out-0102.google.com [64.233.162.202]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k3I3P57I020241 for ; Tue, 18 Apr 2006 05:25:05 +0200 Received: by nz-out-0102.google.com with SMTP id 13so615815nzp for ; Mon, 17 Apr 2006 20:25:05 -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=BlJ2cl2GElSeSNv616u0o3QOAq8pbVd3W5ojARoQx6NxLHCxiY+z5PHKBV3WJpS3rj0wShiDDjFXpwfLsRAkf4mYX/QECuMFjQqt+VuLtNgY+ZFYjbsj2EHxlRXCwJvseVZ4jeypwZrz++V/dKfpw9puPNP7i2w+9cFjr+k311o= Received: by 10.36.252.68 with SMTP id z68mr2709503nzh; Mon, 17 Apr 2006 20:25:03 -0700 (PDT) Received: by 10.36.121.13 with HTTP; Mon, 17 Apr 2006 20:25:03 -0700 (PDT) Message-ID: Date: Tue, 18 Apr 2006 15:25:03 +1200 From: "Jonathan Roewen" To: "Jon Harrop" Subject: Re: [Caml-list] recursion/iterator question Cc: caml-list@yquem.inria.fr In-Reply-To: <200604171807.47687.jon@ffconsultancy.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <1145221898.16349.259200911@webmail.messagingengine.com> <200604170106.23660.jon@ffconsultancy.com> <20060417093635.GB13523@anthony.ics.uci.edu> <200604171807.47687.jon@ffconsultancy.com> X-j-chkmail-Score: MSGID : 44445C11.000 on nez-perce : j-chkmail score : X : 0/20 1 X-Miltered: at nez-perce with ID 44445C11.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; recursion:01 iterator:01 rec:01 ocaml:01 compiler:01 assertion:01 assert:01 caml-list:01 complains:01 matched:01 match:02 let:03 let:03 clause:03 exhaustive:03 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 > > let rec combs =3D function > > > > | (0, _) -> [[]] > > | (n, es) when n > List.length es -> [] > > | (n, e::es) -> List.map (fun l -> e::l) (combs (n-1, es)) @ comb= s > > | (n, es) > > > > let triplets es =3D combs (3, es) > > > > Question to the rest of the list: The ocaml compiler complains with > > ... > > Warning P: this pattern-matching is not exhaustive. > > Here is an example of a value that is not matched: > > (1, []) > > (However, some guarded clause may match this value.) Personally, if you know it can never be reached, then an assertion is probably better. | otherwise -> assert false (* I prefer using a name like otherwise rather than _ for pure readability value *) Jonathan