From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p8ELEaHx004762 for ; Wed, 14 Sep 2011 23:14:37 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AkgFAEAYcU4+3JIEgWdsb2JhbABCmFw0jjgUAQEWJiaBUwEBBAEnRxALCyUhRRIrh2UCArQdhg5gBJM/hRuMDA X-IronPort-AV: E=Sophos;i="4.68,383,1312149600"; d="scan'208";a="119858858" Received: from vs.philou.ch ([62.220.146.4]) by mail1-smtp-roc.national.inria.fr with ESMTP; 14 Sep 2011 23:14:37 +0200 Received: from [192.168.1.120] (85-218-12-84.dclient.lsne.ch [85.218.12.84]) by vs.philou.ch (Postfix) with ESMTPSA id 772A2232178 for ; Wed, 14 Sep 2011 23:14:36 +0200 (CEST) Content-Type: text/plain; charset=iso-8859-1 Mime-Version: 1.0 (Apple Message framework v1084) From: Philippe Strauss In-Reply-To: Date: Wed, 14 Sep 2011 23:14:36 +0200 Message-Id: <249BD60A-712A-4945-ADEF-A94B9C79EE82@philou.ch> References: To: caml-list@inria.fr X-Mailer: Apple Mail (2.1084) Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id p8ELEaHx004762 Subject: Re: [Caml-list] pattern matching on strings It reminds me of the micmatch/mikmatch project(s), http://martin.jambon.free.fr/micmatch.html, but never used it, only remember reading the announce on the hump or this list. Le 14 sept. 2011 à 22:16, Walter Cazzola a écrit : > Hi all, > I'm just trying to write a recursive function that iterates¹ on a string > and I'd like to use pattern matching as in: > > let rec iter f s = > match s with > | "" -> unit; > | c^s1 -> f c; iter f s1;; > > but the ^ concatenates 2 strings and not a char with a string and above > all seems to be inadmissible in the patterns. > > Does this mean that I can't write a function on strings by pattern > matching or is there something I don't know?² > > Thanks for the help > Walter > > ¹ I know that exists String.iter but I'd like to improve my skill in > writing functions by using pattern matching > ² I read about micmatch but I'd like to avoid non standard packages. > -- > -- > Caml-list mailing list. Subscription management and archives: > https://sympa-roc.inria.fr/wws/info/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs >