Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] => Question to the OCaml-team
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: fis@w...
Subject: [Caml-list] => Question to the OCaml-team

> it's nice to have a String.iter, but more functional would
> be to have a 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

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;

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...  (-:


To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: