diff --git a/src/core/CCString.cppo.ml b/src/core/CCString.cppo.ml index 6a06e672..c41f04c0 100644 --- a/src/core/CCString.cppo.ml +++ b/src/core/CCString.cppo.ml @@ -306,13 +306,11 @@ let iter = String.iter #if OCAML_MAJOR >= 4 let map = String.map -let mapi = String.mapi let iteri = String.iteri #else let map f s = init (length s) (fun i -> f s.[i]) -let mapi f s = init (length s) (fun i -> f i s.[i]) let iteri f s = for i = 0 to String.length s - 1 do @@ -321,6 +319,16 @@ let iteri f s = #endif +#if OCAML_MAJOR >= 4 && OCAML_MINOR >= 2 + +let mapi = String.mapi + +#else + +let mapi f s = init (length s) (fun i -> f i s.[i]) + +#endif + let flat_map ?sep f s = let buf = Buffer.create (String.length s) in iteri