caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Richard W.M. Jones" <rich@annexia.org>
To: Basile Starynkevitch <basile@starynkevitch.net>
Cc: Walter Cazzola <cazzola@dico.unimi.it>,
	OCaML Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] pattern matching on strings
Date: Fri, 16 Sep 2011 22:20:05 +0100	[thread overview]
Message-ID: <20110916212005.GA22906@annexia.org> (raw)
In-Reply-To: <20110914224011.70c49bb251e84a4186a2b44d@starynkevitch.net>

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

  reply	other threads:[~2011-09-16 21:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-14 20:16 Walter Cazzola
2011-09-14 20:40 ` Basile Starynkevitch
2011-09-16 21:20   ` Richard W.M. Jones [this message]
2011-09-17  8:15     ` Basile Starynkevitch
2011-09-14 20:57 ` Philippe Veber
2011-09-14 21:44   ` Raphael Proust
2011-09-16 22:18     ` Philippe Veber
2011-09-14 21:14 ` Philippe Strauss

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110916212005.GA22906@annexia.org \
    --to=rich@annexia.org \
    --cc=basile@starynkevitch.net \
    --cc=caml-list@inria.fr \
    --cc=cazzola@dico.unimi.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).