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 TAA24106; Mon, 28 Jun 2004 19:11:14 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id TAA24095 for ; Mon, 28 Jun 2004 19:11:13 +0200 (MET DST) Received: from ptb-relay01.plus.net (ptb-relay01.plus.net [212.159.14.212]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i5SHBCEV002869 for ; Mon, 28 Jun 2004 19:11:12 +0200 Received: from [80.229.56.224] (helo=chetara) by ptb-relay01.plus.net with esmtp (Exim) id 1Bezex-000BYo-Ie for caml-list@inria.fr; Mon, 28 Jun 2004 17:11:11 +0000 From: Jon Harrop To: caml-list Subject: Re: [Caml-list] Pattern matching over elements at the front of a container Date: Mon, 28 Jun 2004 18:09:06 +0100 User-Agent: KMail/1.6.2 References: <200406261215.26971.postmaster@jdh30.plus.com> <200406281301.01048.postmaster@jdh30.plus.com> <20040628145053.A29706@beaune.inria.fr> In-Reply-To: <20040628145053.A29706@beaune.inria.fr> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200406281809.06524.postmaster@jdh30.plus.com> X-Miltered: at nez-perce with ID 40E05130.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; postmaster:99 caml-list:01 2004:99 bindings:01 maranget:02 imply:02 implicit:02 binding:03 wrote:03 tail:03 cons:03 cons:03 elegant:04 let:04 array:04 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Monday 28 June 2004 13:50, Luc Maranget wrote: > ... > Your ``...'' are sequences (?) they imply additional costs > (BTY one can also consider those for lists , written for instance > ... @ [1] @ ... ) I was working on the implicit assumption that bindings could only appear at the ends of the array and, therefore, pattern matching (e.g. [|h; ..|], [|..; h|] or [|h1; ..; h2|]) can all be guaranteed to be O(1) because they equate to, for example, "if Array.length a>1 then ..." with a binding for h equivalent to "let h=Array.get a 1 in ...". This seems (to me) to be an elegant equivalent to cons on lists although, of course, you can't access the tail in O(1) in the case of an array (hence I'm not allowing it to be named) and you can't reverse the meaning of the cons in O(1) on a list. I wasn't suggesting that something like [|..; h1; ..; h2; ..|] be allowed. I'll swat up on the rest (e.g. the Church-Rosser property) before replying, but I think I understand and agree with what you're saying. Cheers, Jon. ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners