From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p8EKGwTf002587 for ; Wed, 14 Sep 2011 22:16:58 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ao4DAOYKcU6flYLKZGdsb2JhbABBp0gIFw0LBhUmggGCBAyIDJVzn3eGbgSTP4UJEowM X-IronPort-AV: E=Sophos;i="4.68,382,1312149600"; d="scan'208";a="109095155" Received: from smtp.dico.unimi.it ([159.149.130.202]) by mail4-smtp-sop.national.inria.fr with ESMTP; 14 Sep 2011 22:16:52 +0200 Received: from [192.168.1.100] (dynamic-adsl-94-36-47-184.clienti.tiscali.it [94.36.47.184]) (authenticated bits=0) by smtp.dico.unimi.it (8.14.4/8.14.4) with ESMTP id p8EKGl3x017437 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 14 Sep 2011 22:16:48 +0200 Date: Wed, 14 Sep 2011 22:16:42 +0200 (CEST) From: Walter Cazzola To: OCaML Mailing List Message-ID: User-Agent: Alpine 2.00 (LFD 1167 2008-08-23) MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="8323328-1838216649-1316031408=:2647" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0 (smtp.dico.unimi.it [159.149.130.202]); Wed, 14 Sep 2011 22:16:48 +0200 (CEST) X-DSI-MailScanner-Information: Please contact the staff for more information X-DSI-MailScanner-ID: p8EKGl3x017437 X-DSI-MailScanner: Found to be clean X-DSI-MailScanner-From: cazzola@dico.unimi.it Subject: [Caml-list] pattern matching on strings This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323328-1838216649-1316031408=:2647 Content-Type: TEXT/PLAIN; format=flowed; charset=ISO-8859-15 Content-Transfer-Encoding: 8BIT 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. -- --8323328-1838216649-1316031408=:2647--