From: Florent Ouchet <florent.ouchet@imag.fr>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] integer regular expressions
Date: Tue, 31 Mar 2009 11:11:24 +0200 [thread overview]
Message-ID: <49D1DE3C.3030103@imag.fr> (raw)
In-Reply-To: <49D17BAF.1060702@ens-lyon.org>
[-- Attachment #1: Type: text/plain, Size: 1342 bytes --]
Martin Jambon a écrit :
> You want something called "views" or "active patterns".
> You can do that in OCaml with mikmatch, which includes such syntax extension.
>
> See http://martin.jambon.free.fr/mikmatch-manual.html#htoc10
>
> Here is your example:
>
> let view Mod30 = fun x -> x mod 30 = 0
> (*
> but not:
> let view Mod m = fun x -> x mod m = 0
>
> but it could be implemented without difficulty (if really needed).
> *)
>
>
> let test x =
> match x with
> %Mod30 -> ...
> | ... ->
>
>
> Of course the whole point is to use %Mod30 within arbitrary patterns,
> otherwise it wouldn't be useful.
>
> I you want to match regular expressions over anything else than bytes, there's
> nothing out-of-the-box. You can define views on lists that would consume any
> number of elements, but it is pretty limited.
>
Hello Martin,
That's an elegant way for writing custom pattern matches in OCaml code
but that is not exactly what I am looking for. Your proposal fits well
for fixed pattern matches while I would like to make the regular
expressions customizable via the application command line (ie at
run-time). A module dedicated to integer matches (like RegExp is to
string matches) would fit better.
Regards,
Florent
VSYML - VHDL Symbolic Simulator in OCaml:
http://users-tima.imag.fr/vds/ouchet/vsyml.html
[-- Attachment #2: florent.ouchet.vcf --]
[-- Type: text/x-vcard, Size: 309 bytes --]
begin:vcard
fn:Florent Ouchet
n:Ouchet;Florent
org:;CIS/VDS
adr;quoted-printable:46, avenue F=C3=A9lix Viallet,;;TIMA Laboratory - T131;GRENOBLE Cedex;;38031;France
email;internet:florent.ouchet@imag.fr
title:PhD student
tel;work:0476574872
x-mozilla-html:FALSE
url:http://tima.imag.fr
version:2.1
end:vcard
prev parent reply other threads:[~2009-03-31 9:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-30 17:21 Florent.Ouchet
2009-03-31 2:10 ` [Caml-list] " Martin Jambon
2009-03-31 9:11 ` Florent Ouchet [this message]
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=49D1DE3C.3030103@imag.fr \
--to=florent.ouchet@imag.fr \
--cc=caml-list@yquem.inria.fr \
/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