From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id RAA21003; Thu, 8 Nov 2001 17:25:40 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id RAA21602 for ; Thu, 8 Nov 2001 17:25:39 +0100 (MET) Received: from smtp2.cswv.com (smtp2.cswv.com [4.17.129.20]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id fA8GPbX28375 for ; Thu, 8 Nov 2001 17:25:38 +0100 (MET) Received: from smtp2.cswv.com ([10.2.3.6]) by smtp2.cswv.com with Microsoft SMTPSVC(5.5.1877.197.19); Thu, 8 Nov 2001 11:25:31 -0500 Received: FROM exchange1.cswv.com BY smtp2.cswv.com ; Thu Nov 08 11:25:30 2001 -0500 Received: by exchange1.cswv.com with Internet Mail Service (5.5.2653.19) id ; Thu, 8 Nov 2001 11:29:10 -0500 Message-ID: From: "Krishnaswami, Neel" To: "'Rolf Wester'" , caml-list@inria.fr Subject: RE: [Caml-list] Warning: this match case is unused. Date: Thu, 8 Nov 2001 11:29:01 -0500 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain; charset="iso-8859-1" Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Rolf Wester [mailto:rolf.wester@ilt.fhg.de] wrote: > > this is probably a trivial question but can someone tell me why: > > let f l n0 = > let n = List.length l in > match n with > n0 -> 1; > | _ -> 0;; > > Results in: > Warning: this match case is unused. Yes. Your function will always return 1, because variables on the left-hand side of a pattern-match are bound like in a let expression. So the first branch of the match will always succeed, binding n0 to n, and then return 1. So your code is equivalent to: let f l n0 = let n = List.length l in let n0 = n in 1 which is probably not what you want. :) Try writing this as: let f l n0 = let n = List.length l in if n = n0 then 1 else 0 -- Neel Krishnaswami neelk@cswcasa.com ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr