From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: weis Received: (from weis@localhost) by pauillac.inria.fr (8.6.10/8.6.6) with ESMTP id KAA03767; Fri, 6 Sep 1996 10:31:58 +0200 Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.7.1/8.7.1) with ESMTP id KAA26643; Fri, 6 Sep 1996 10:30:30 +0200 (MET DST) Received: (from weis@localhost) by pauillac.inria.fr (8.6.10/8.6.6) id KAA03251 for caml-redistribution; Fri, 6 Sep 1996 10:17:41 +0200 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.6.10/8.6.6) with ESMTP id TAA21315 for ; Thu, 5 Sep 1996 19:25:20 +0200 Received: from ayax.uniandes.edu.co (ayax.uniandes.edu.co [157.253.50.3]) by concorde.inria.fr (8.7.1/8.7.1) with SMTP id TAA20246 for ; Thu, 5 Sep 1996 19:25:07 +0200 (MET DST) Received: from e-posse.uniandes.edu.co by ayax.uniandes.edu.co (SMI-8.6/SMI-SVR4) id MAA05258; Thu, 5 Sep 1996 12:26:45 +0500 Message-ID: <322F0B89.553@isis.uniandes.edu.co> Date: Thu, 05 Sep 1996 12:19:05 -0500 From: Ernesto Posse Reply-To: e-posse@uniandes.edu.co X-Mailer: Mozilla 3.0 (Win95; I) MIME-Version: 1.0 To: Caml List Subject: Pattern Matching Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: Pierre.Weis@inria.fr Hello everyone. I have a question about pattern matching. I need a function which binds an identifier to a value in certain data structure (which is called "heap" here). This is actually a (string * record) list. It is not suppose to be a mutable data structure, so the binding just creates a new list copying the same values as the old one with the exception of the record to be changed. For this purpose I am using List.map (I am using O'Caml 1.01 for Windows 95): let assign heap id obj = List.map ( function (id,{ vartype = vt; contents = v; constraints = c; dependencies = d }) -> (id,{ vartype = vt; contents = obj; constraints = c; dependencies = d }) | r -> r ) (* 1 *) heap However the compiler tells me that line marked (* 1 *) is an unused case of the match expression. I thought that maybe the problem was that the inner id variables (the ones in the function passed to map) are identifier patterns therefor they are different from the parameter of the assign function. So I tried to fix it like this: let assign heap id obj = List.map ( function (name,{ vartype = vt; contents = v; constraints = c; dependencies = d }) when name = id -> (name,{ vartype = vt; contents = obj; constraints = c; dependencies = d }) | (name,_) as r when name <> id -> r ) heap And now I get the warning "this pattern-matching is not exhaustive". Can anyone tell me what is wrong with this possibilities and how could I solve the problem ? Thank you very much. -- Ernesto Posse Estudiante de Ingenieria de Sistemas y Computacion (Systems and Computing Engineering student) Universidad de los Andes Santafe de Bogota Colombia e-mail: e-posse@uniandes.edu.co