From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id TAA10695 for caml-redistribution; Wed, 27 Jan 1999 19:28:17 +0100 (MET) 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 PAA08087 for ; Wed, 27 Jan 1999 15:03:01 +0100 (MET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.8.7/8.8.7) with ESMTP id PAA23533; Wed, 27 Jan 1999 15:02:50 +0100 (MET) Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id PAA15684; Wed, 27 Jan 1999 15:02:50 +0100 (MET) From: Pierre Weis Message-Id: <199901271402.PAA15684@pauillac.inria.fr> Subject: Re: [Q] Multiple patterns in O'Caml To: matias@k-bell.com Date: Wed, 27 Jan 1999 15:02:49 +0100 (MET) Cc: caml-list@inria.fr In-Reply-To: <36AE0E34.6BF3A367@k-bell.com> from "=?iso-8859-1?Q?Mat=EDas?= Giovannini" at Jan 26, 99 03:49:28 pm X-Mailer: ELM [version 2.4 PL24 ME8] MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Sender: weis > (* In O'Caml *) > let rec drop n l = match (n,l) with > | 0,l -> l > | n,[] -> failwith "drop" > | n,a::x -> drop (pred n) x > ;; > > but this requires an extraneous tuple construction and its subsequent > destruction, and kinda seems wasteful to me. > > Thank you in advance, best regards > Matías. There is no spurious construction of tuples nor subsequent destuction when matching an immediate tuple: this is optimised by the compiler of Objective Caml. This way you can consider writing match x, y, z with | 1, 2, 3 -> ... ... as a syntactic notation for ``parallel matching'', or matching of more than one value at a time. Pierre Weis INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://cristal.inria.fr/~weis/