mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-07 03:35:30 -05:00
add CCString.split_on_char
This commit is contained in:
parent
48bb1e24c6
commit
ef651342eb
2 changed files with 18 additions and 0 deletions
|
|
@ -388,6 +388,20 @@ module Split = struct
|
||||||
let right ~by s = try Some (right_exn ~by s) with Not_found -> None
|
let right ~by s = try Some (right_exn ~by s) with Not_found -> None
|
||||||
end
|
end
|
||||||
|
|
||||||
|
let split_on_char c s: _ list =
|
||||||
|
Split.list_cpy ~by:(String.make 1 c) s
|
||||||
|
|
||||||
|
(*$= & ~printer:Q.Print.(list string)
|
||||||
|
["a"; "few"; "words"; "from"; "our"; "sponsors"] \
|
||||||
|
(split_on_char ' ' "a few words from our sponsors")
|
||||||
|
*)
|
||||||
|
|
||||||
|
(*$Q
|
||||||
|
Q.(printable_string) (fun s -> \
|
||||||
|
let s = split_on_char ' ' s |> String.concat " " in \
|
||||||
|
s = split_on_char ' ' s |> String.concat " ")
|
||||||
|
*)
|
||||||
|
|
||||||
let compare_versions a b =
|
let compare_versions a b =
|
||||||
let of_int s = try Some (int_of_string s) with _ -> None in
|
let of_int s = try Some (int_of_string s) with _ -> None in
|
||||||
let rec cmp_rec a b = match a(), b() with
|
let rec cmp_rec a b = match a(), b() with
|
||||||
|
|
|
||||||
|
|
@ -495,6 +495,10 @@ module Split : sig
|
||||||
*)
|
*)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
val split_on_char : char -> string -> string list
|
||||||
|
(** Split the string along the given char
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
(** {2 Utils} *)
|
(** {2 Utils} *)
|
||||||
|
|
||||||
val compare_versions : string -> string -> int
|
val compare_versions : string -> string -> int
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue