From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.4 required=5.0 tests=SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 3A7D6BBC4 for ; Tue, 31 Mar 2009 11:24:21 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AmoCAId+0UmBWB4BmWdsb2JhbACWAgEBAQEBCAsKBxG2dIN6Bg X-IronPort-AV: E=Sophos;i="4.38,451,1233529200"; d="vcf'?scan'208";a="25329817" Received: from imag.imag.fr ([129.88.30.1]) by mail3-smtp-sop.national.inria.fr with ESMTP; 31 Mar 2009 11:24:04 +0200 Received: from rubi.imag.fr (rubi.imag.fr [147.171.129.3]) by imag.imag.fr (8.13.8/8.13.8) with ESMTP id n2V9KdtQ026035 for ; Tue, 31 Mar 2009 11:20:40 +0200 (CEST) Received: from [147.171.140.31] (diamante.imag.fr [147.171.140.31]) by rubi.imag.fr (8.11.7p2+Sun/8.11.3/ImagV2) with ESMTP id n2V9bFI03056 for ; Tue, 31 Mar 2009 11:37:15 +0200 (MEST) Message-ID: <49D1DE3C.3030103@imag.fr> Date: Tue, 31 Mar 2009 11:11:24 +0200 From: Florent Ouchet Reply-To: florent.ouchet@imag.fr Organization: Tima/VDS User-Agent: IceDove 1.5.0.14eol (X11/20080509) MIME-Version: 1.0 To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] integer regular expressions References: <20090330192129.32152seaqvtmfb15@webmail.imag.fr> <49D17BAF.1060702@ens-lyon.org> In-Reply-To: <49D17BAF.1060702@ens-lyon.org> Content-Type: multipart/mixed; boundary="------------040701030804060705020607" X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-3.0 (imag.imag.fr [129.88.30.1]); Tue, 31 Mar 2009 11:20:40 +0200 (CEST) X-IMAG-MailScanner-Information: Please contact MI2S MIM for more information X-IMAG-MailScanner: Found to be clean X-IMAG-MailScanner-SpamCheck: X-IMAG-MailScanner-From: florent.ouchet@imag.fr X-Spam: no; 0.00; ocaml:01 syntax:01 ocaml:01 run-time:01 regexp:01 integer:01 integer:01 symbolic:01 caml-list:01 jambon:01 jambon:01 arbitrary:02 define:02 implemented:02 match:02 X-Attachments: cset="utf-8" name="florent.ouchet.vcf" name="florent.ouchet.vcf" This is a multi-part message in MIME format. --------------040701030804060705020607 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit 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 --------------040701030804060705020607 Content-Type: text/x-vcard; charset=utf-8; name="florent.ouchet.vcf" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="florent.ouchet.vcf" 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 --------------040701030804060705020607--