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