Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Warning: this match case is unused.
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Yann Coscoy <Yann.Coscoy@t...>
Subject: Re: [Caml-list] Warning: this match case is unused.
Rolf Wester wrote:

> Hi,
> 
> 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.


The second n0 in pattern « n0 -> 1 » is the introduction of a fresh 
variable. It is not binded to n0 previously introduced in « f l n0 = ».

I guess the function you had in mind is:


let f l n0 =
  let n = List.length l in
  match n with 
	  n1 when n1=n0 -> 1;
	| _  -> 0;;





-- 
Yann Coscoy - Trusted Logic
5 rue du Bailliage 78000 Versailles
+33 (0) 1 30 97 74 76
http://www.trusted-logic.fr


-------------------
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