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 TAA28966; Fri, 9 Apr 2004 19:00:49 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id TAA28348 for ; Fri, 9 Apr 2004 19:00:48 +0200 (MET DST) From: brogoff@speakeasy.net Received: from mail1.speakeasy.net (mail1.speakeasy.net [216.254.0.201]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i39H1fjq015847 for ; Fri, 9 Apr 2004 19:01:42 +0200 Received: (qmail 6488 invoked from network); 9 Apr 2004 17:00:45 -0000 Received: from grace.speakeasy.net ([216.254.0.22]) (envelope-sender ) by mail1.speakeasy.net (qmail-ldap-1.03) with AES256-SHA encrypted SMTP for ; 9 Apr 2004 17:00:45 -0000 Date: Fri, 9 Apr 2004 10:00:44 -0700 (PDT) To: caml-list@inria.fr Subject: Re: [Caml-list] String.map => Question to the OCaml-team In-Reply-To: <20040409145652.GB27343@gaia.cc.gatech.edu> Message-ID: References: <20040409110138.GA1333@first.in-berlin.de> <16502.38522.179048.194250@gargle.gargle.HOWL> <16502.42309.605598.795600@gargle.gargle.HOWL> <20040409145652.GB27343@gaia.cc.gatech.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Miltered: at nez-perce by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; brogoff:01 caml-list:01 ocaml-team:01 alegre:01 2004:99 filliatre:01 for':99 char:01 char:01 blit:01 modeled:01 haskell:01 abominable:01 generic:01 bigarrays:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk X-Status: X-Keywords: X-UID: 221 On Fri, 9 Apr 2004, Fernando Alegre wrote: > On Fri, Apr 09, 2004 at 03:29:41PM +0200, Jean-Christophe Filliatre wrote: > > > Note there is a `for' construct in ocaml: > > > > ====================================================================== > > let string_map (f: char -> char) (s: string) : string = > > let t = String.copy s in > > for i = 0 to String.length s - 1 do t.[i] <- f s.[i] done; > > t > > ====================================================================== > > > > and this is slightly faster than your implementation (by 10%). > > Why not just use String.blit, as provided by the standard library? > > Fernando > The whole thing would be a lot nicer if there were a String.init init : int -> (int -> char) -> string obviously modeled on Array.init, since the OCaml designers had enough good sense not to follow Haskell and make strings lists (or provide abominable built in string -> char list functions). I wonder how usefulthis is in typical string manipulation? I guess I find other ways to do things... It would of course be nice if we had the oft discussed generic polymorphism so that we could take better advantage of the similarity of strings and arrays (and bigarrays and hastables and ...) than we can now. Bazaar to Cathedral, anyone home? :-) Also, ripping off SML97 Basis Substring makes a lot of sense. Substrings allow you to write these string traversal algorithms over in a functional style, which is usually a good thing. -- Brian ------------------- 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