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 2486EBB84 for ; Mon, 17 Apr 2006 19:05:52 +0200 (CEST) Received: from ptb-relay01.plus.net (ptb-relay01.plus.net [212.159.14.212]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k3HH5p79002029 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO) for ; Mon, 17 Apr 2006 19:05:51 +0200 Received: from [80.229.56.224] (helo=chetara) by ptb-relay01.plus.net with esmtp (Exim) id 1FVXAd-0006a9-6D for caml-list@yquem.inria.fr; Mon, 17 Apr 2006 18:05:51 +0100 From: Jon Harrop Organization: Flying Frog Consultancy Ltd. To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] recursion/iterator question Date: Mon, 17 Apr 2006 18:07:47 +0100 User-Agent: KMail/1.9.1 References: <1145221898.16349.259200911@webmail.messagingengine.com> <200604170106.23660.jon@ffconsultancy.com> <20060417093635.GB13523@anthony.ics.uci.edu> In-Reply-To: <20060417093635.GB13523@anthony.ics.uci.edu> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200604171807.47687.jon@ffconsultancy.com> X-Miltered: at nez-perce with ID 4443CAEF.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 ocaml:01 2006:98 frog:98 wrote:01 caml-list:01 complains:01 matched:01 short:01 patterns:02 patterns: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 On Monday 17 April 2006 10:36, Christian Stork wrote: > Or, if you choose to represent triplets as lists of three elements, you can > generalize Jon's solution to > > let rec combs = function > > | (0, _) -> [[]] > | (n, es) when n > List.length es -> [] > | (n, e::es) -> List.map (fun l -> e::l) (combs (n-1, es)) @ combs > | (n, es) > > let triplets es = 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.) > ... > > Am I right to assume there's no way to get rid of this warning short of > disabling P-warnings on the command line? (I can't list all the lacking > patterns since they depend on n, right?) The lacking patterns are covered by (_, []), so you probably want: | 0, _ | _, [] -> [[]] -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. Objective CAML for Scientists http://www.ffconsultancy.com/products/ocaml_for_scientists