From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p8GLK5CW021157 for ; Fri, 16 Sep 2011 23:20:08 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av0EABy9c05QRFuw/2dsb2JhbABBp2B3gVMBAQUnEz8QCxgcEhQoIYgMtFWGGGAEpHc X-IronPort-AV: E=Sophos;i="4.68,395,1312149600"; d="scan'208";a="109386732" Received: from furbychan.cocan.org ([80.68.91.176]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/AES256-SHA; 16 Sep 2011 23:20:08 +0200 Received: from rich by furbychan.cocan.org with local (Exim 4.72) (envelope-from ) id 1R4fpN-0006ge-Vm; Fri, 16 Sep 2011 22:20:06 +0100 Date: Fri, 16 Sep 2011 22:20:05 +0100 From: "Richard W.M. Jones" To: Basile Starynkevitch Cc: Walter Cazzola , OCaML Mailing List Message-ID: <20110916212005.GA22906@annexia.org> References: <20110914224011.70c49bb251e84a4186a2b44d@starynkevitch.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20110914224011.70c49bb251e84a4186a2b44d@starynkevitch.net> User-Agent: Mutt/1.5.20 (2009-06-14) Subject: Re: [Caml-list] pattern matching on strings On Wed, Sep 14, 2011 at 10:40:11PM +0200, Basile Starynkevitch wrote: > And there is a reason why you cannot match (in Ocaml) on the content > of strings (or arrays). It won't be easy to implement efficiently > (you would need to copy a substring or subarray when matching) How about just prefix matching? That on its own would be very useful. For example in web app that was passed arguments foo_1, foo_2, bar_1, bar_5 you could parse the arguments like this: match arg with | "foo_" ^ s -> (* ... *) | "bar_" ^ s -> (* ... *) Rich. -- Richard Jones Red Hat