From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id OAA07856; Fri, 9 Apr 2004 14:28:40 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id OAA08016 for ; Fri, 9 Apr 2004 14:28:39 +0200 (MET DST) From: fis@wiwi.hu-berlin.de Received: from miro.wiwi.hu-berlin.de (miro.wiwi.hu-berlin.de [141.20.103.80]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i39CScYM032713 for ; Fri, 9 Apr 2004 14:28:38 +0200 Received: from mini (miro [141.20.103.80]) by miro.wiwi.hu-berlin.de (8.11.7+Sun/8.8.6) with ESMTP id i39CSb102959 for ; Fri, 9 Apr 2004 14:28:37 +0200 (MET DST) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16502.38522.179048.194250@gargle.gargle.HOWL> Date: Fri, 9 Apr 2004 14:26:34 +0200 To: caml-list@inria.fr Subject: [Caml-list] String.map => Question to the OCaml-team In-Reply-To: <20040409110138.GA1333@first.in-berlin.de> References: <20040409110138.GA1333@first.in-berlin.de> X-Miltered: at concorde by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 ocaml-team:01 char:01 char:01 incr:01 matthias:01 ocaml:01 int:01 int:01 string:03 string:03 iter:03 iter:03 let:04 let:04 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk X-Status: X-Keywords: X-UID: 211 > it's nice to have a String.iter, but more functional would > be to have a String.map function. I don't know much about ocaml, but my bet is the implementation of strings doens't allow for anything considerably more efficient than this: let string_map (f: char -> char) (s: string) : string = let t = String.copy s in let i = ref 0 in String.iter (fun c -> let d = f c in String.set t !i d; incr i) s; t;; to test, type: let s = "a=b1";; let t = string_map (fun c -> char_of_int (int_of_char c + 1)) s;; Does this generate optimal code, or where not? What are the technical / political procedures to put these lines into the next distribution? Are there any good reasons against doing so? Well, I guess there always are... (-: curious, matthias ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners