mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
add CCString.{lines,unlines} that work on lines
This commit is contained in:
parent
0b38c9e272
commit
ef92ef19fd
2 changed files with 18 additions and 6 deletions
|
|
@ -263,7 +263,9 @@ let of_array a =
|
||||||
let to_array s =
|
let to_array s =
|
||||||
Array.init (String.length s) (fun i -> s.[i])
|
Array.init (String.length s) (fun i -> s.[i])
|
||||||
|
|
||||||
let lines s = Split.gen_cpy ~by:"\n" s
|
let lines_gen s = Split.gen_cpy ~by:"\n" s
|
||||||
|
|
||||||
|
let lines s = Split.list_cpy ~by:"\n" s
|
||||||
|
|
||||||
let concat_gen ~sep g =
|
let concat_gen ~sep g =
|
||||||
let b = Buffer.create 256 in
|
let b = Buffer.create 256 in
|
||||||
|
|
@ -275,7 +277,9 @@ let concat_gen ~sep g =
|
||||||
aux ~first:false ()
|
aux ~first:false ()
|
||||||
in aux ~first:true ()
|
in aux ~first:true ()
|
||||||
|
|
||||||
let unlines g = concat_gen ~sep:"\n" g
|
let unlines l = String.concat "\n" l
|
||||||
|
|
||||||
|
let unlines_gen g = concat_gen ~sep:"\n" g
|
||||||
|
|
||||||
let pp buf s =
|
let pp buf s =
|
||||||
Buffer.add_char buf '"';
|
Buffer.add_char buf '"';
|
||||||
|
|
|
||||||
|
|
@ -113,16 +113,24 @@ val suffix : suf:string -> string -> bool
|
||||||
not (suffix ~suf:"abcd" "cd")
|
not (suffix ~suf:"abcd" "cd")
|
||||||
*)
|
*)
|
||||||
|
|
||||||
val lines : string -> string gen
|
val lines : string -> string list
|
||||||
(** [lines s] returns a generator of the lines of [s] (splits along '\n')
|
(** [lines s] returns a list of the lines of [s] (splits along '\n')
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
|
val lines_gen : string -> string gen
|
||||||
|
(** [lines_gen s] returns a generator of the lines of [s] (splits along '\n')
|
||||||
@since NEXT_RELEASE *)
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
val concat_gen : sep:string -> string gen -> string
|
val concat_gen : sep:string -> string gen -> string
|
||||||
(** [concat_gen ~sep g] concatenates all strings of [g], separated with [sep].
|
(** [concat_gen ~sep g] concatenates all strings of [g], separated with [sep].
|
||||||
@since NEXT_RELEASE *)
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
val unlines : string gen -> string
|
val unlines : string list -> string
|
||||||
(** [unlines g] concatenates all strings of [g], separated with '\n'
|
(** [unlines l] concatenates all strings of [l], separated with '\n'
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
|
val unlines_gen : string gen -> string
|
||||||
|
(** [unlines_gen g] concatenates all strings of [g], separated with '\n'
|
||||||
@since NEXT_RELEASE *)
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
(*$Q
|
(*$Q
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue