caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Nicolas Cannasse" <warplayer@free.fr>
To: <brogoff@speakeasy.net>, <caml-list@inria.fr>
Subject: Re: [Caml-list] String.map => Question to the OCaml-team
Date: Fri, 9 Apr 2004 20:26:46 +0200	[thread overview]
Message-ID: <004301c41e60$377f4d80$19b0e152@warp> (raw)
In-Reply-To: <Pine.LNX.4.58.0404090942090.9039@grace.speakeasy.net>

> > > 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? :-)

Look at ExtLib :-)
we added String.init and we have Enum module which can play with String as
Array of chars without actually allocating an array of chars.
http://ocaml-lib.sf.net
Of course generics would add more sugar into our everyday caml coffee.

Regards,
Nicolas Cannasse

-------------------
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


  reply	other threads:[~2004-04-09 18:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-04-09 11:01 Oliver Bandel
2004-04-09 12:26 ` fis
2004-04-09 13:29   ` Jean-Christophe Filliatre
2004-04-09 14:44     ` fis
2004-04-09 15:12       ` Correnson Loïc
2004-04-09 14:56     ` Fernando Alegre
2004-04-09 17:00       ` brogoff
2004-04-09 18:26         ` Nicolas Cannasse [this message]
2004-04-09 12:28 ` Jon Harrop
2004-04-10 10:14   ` skaller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='004301c41e60$377f4d80$19b0e152@warp' \
    --to=warplayer@free.fr \
    --cc=brogoff@speakeasy.net \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).