String.map was added in OCaml 4.00.0. However we use this function to implement String.lowercase_ascii etc. Therefore include a definition of the function for older versions of OCaml. (Debian Wheezy has OCaml 3.12.1.) --- mllib/common_utils.ml | 8 ++++++++ mllib/common_utils.mli | 2 ++ 2 files changed, 10 insertions(+) diff --git a/mllib/common_utils.ml b/mllib/common_utils.ml index 9210cf8..4e36d50 100644 --- a/mllib/common_utils.ml +++ b/mllib/common_utils.ml @@ -38,6 +38,14 @@ end module String = struct include String + let map f s = + let len = String.length s in + let b = Bytes.create len in + for i = 0 to len-1 do + Bytes.unsafe_set b i (f (unsafe_get s i)) + done; + Bytes.to_string b + let lowercase_ascii s = map Char.lowercase_ascii s let uppercase_ascii s = map Char.uppercase_ascii s diff --git a/mllib/common_utils.mli b/mllib/common_utils.mli index 4959de6..de95f9d 100644 --- a/mllib/common_utils.mli +++ b/mllib/common_utils.mli @@ -49,6 +49,8 @@ module String : sig val sub : string -> int -> int -> string val unsafe_get : string -> int -> char + val map : (char -> char) -> string -> string + val lowercase_ascii : string -> string val uppercase_ascii : string -> string -- 2.7.4