mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 03:05:28 -05:00
reindent
This commit is contained in:
parent
7510aaaa18
commit
b3c796176d
6 changed files with 17 additions and 17 deletions
|
|
@ -390,7 +390,7 @@ let ksprintf ~f fmt =
|
|||
(Some "hello world") \
|
||||
(ksprintf "hello %a" CCFormat.string "world" ~f:(fun s -> Some s))
|
||||
*)
|
||||
|
||||
|
||||
module Dump = struct
|
||||
type 'a t = 'a printer
|
||||
let unit = unit
|
||||
|
|
|
|||
|
|
@ -1265,7 +1265,7 @@ let replicate i x =
|
|||
Q.(pair small_int (small_list int)) (fun (n,l) -> \
|
||||
if n>0 then repeat n l = flat_map (fun _ -> l) (1--n) \
|
||||
else Q.assume_fail())
|
||||
*)
|
||||
*)
|
||||
|
||||
let repeat i l =
|
||||
let rec aux acc i =
|
||||
|
|
|
|||
|
|
@ -339,7 +339,7 @@ val sorted_insert : cmp:('a -> 'a -> int) -> ?uniq:bool -> 'a -> 'a list -> 'a l
|
|||
@param uniq if true and [x] is already in sorted position in [l], then
|
||||
[x] is not duplicated. Default [false] ([x] will be inserted in any case).
|
||||
@since 0.17 *)
|
||||
|
||||
|
||||
val uniq_succ : eq:('a -> 'a -> bool) -> 'a list -> 'a list
|
||||
(** [uniq_succ l] removes duplicate elements that occur one next to the other.
|
||||
Examples:
|
||||
|
|
|
|||
|
|
@ -287,7 +287,7 @@ let find ?(start=0) ~sub =
|
|||
let i = find ~sub:s2 s1 in \
|
||||
i < 0 || String.sub s1 i (length s2) = s2)
|
||||
*)
|
||||
|
||||
|
||||
let find_all ?(start=0) ~sub =
|
||||
let pattern = Find.compile sub in
|
||||
fun s ->
|
||||
|
|
@ -313,14 +313,14 @@ let find_all_l ?start ~sub s =
|
|||
[76] (find_all_l ~sub:"aaaaaa" \
|
||||
"aabbaabbaaaaabbbbabababababbbbabbbabbaaababbbaaabaabbaabbaaaabbababaaaabbaabaaaaaabbbaaaabababaabaaabbaabaaaabbababbaabbaaabaabbabababbbaabababaaabaaababbbaaaabbbaabaaababbabaababbaabbaaaaabababbabaababbbaaabbabbabababaaaabaaababaaaaabbabbaabbabbbbbbbbbbbbbbaabbabbbbbabbaaabbabbbbabaaaaabbababbbaaaa")
|
||||
*)
|
||||
|
||||
|
||||
let mem ?start ~sub s = find ?start ~sub s >= 0
|
||||
|
||||
(*$T
|
||||
mem ~sub:"bc" "abcd"
|
||||
not (mem ~sub:"a b" "abcd")
|
||||
*)
|
||||
|
||||
|
||||
let rfind ~sub =
|
||||
let pattern = Find.rcompile sub in
|
||||
fun s -> Find.rfind ~start:(String.length s-1) ~pattern s
|
||||
|
|
@ -508,7 +508,7 @@ module Split = struct
|
|||
Split.right ~by:"_" "abcde" = None
|
||||
Split.right ~by:"a_" "abcde" = None
|
||||
*)
|
||||
|
||||
|
||||
end
|
||||
|
||||
let split_on_char c s: _ list =
|
||||
|
|
@ -848,10 +848,10 @@ let of_list l =
|
|||
of_list ['a'; 'b'; 'c'] = "abc"
|
||||
of_list [] = ""
|
||||
*)
|
||||
|
||||
|
||||
let of_array a =
|
||||
init (Array.length a) (fun i -> a.(i))
|
||||
|
||||
|
||||
let to_array s =
|
||||
Array.init (String.length s) (fun i -> s.[i])
|
||||
|
||||
|
|
@ -1136,7 +1136,7 @@ module Sub = struct
|
|||
|> Sequence.for_all
|
||||
(fun (i,j,sub) -> Sub.get sub j = s.[i+j]))
|
||||
*)
|
||||
|
||||
|
||||
let to_gen (s,i,len) = _to_gen s i len
|
||||
let to_seq (s,i,len) k =
|
||||
for i=i to i+len-1 do k s.[i] done
|
||||
|
|
|
|||
|
|
@ -107,13 +107,13 @@ val of_list : char list -> string
|
|||
|
||||
val of_array : char array -> string
|
||||
(** Convert an array of characters to a string. *)
|
||||
|
||||
|
||||
val to_array : string -> char array
|
||||
(** Return the array of characters contained in the string. *)
|
||||
|
||||
val find : ?start:int -> sub:string -> string -> int
|
||||
(** Find [sub] in string, returns its first index or [-1]. *)
|
||||
|
||||
|
||||
val find_all : ?start:int -> sub:string -> string -> int gen
|
||||
(** [find_all ~sub s] finds all occurrences of [sub] in [s], even overlapping
|
||||
instances.
|
||||
|
|
@ -125,11 +125,11 @@ val find_all_l : ?start:int -> sub:string -> string -> int list
|
|||
them in a list.
|
||||
@param start starting position in [s].
|
||||
@since 0.17 *)
|
||||
|
||||
|
||||
val mem : ?start:int -> sub:string -> string -> bool
|
||||
(** [mem ~sub s] is true iff [sub] is a substring of [s].
|
||||
@since 0.12 *)
|
||||
|
||||
|
||||
val rfind : sub:string -> string -> int
|
||||
(** Find [sub] in string from the right, returns its first index or [-1].
|
||||
Should only be used with very small [sub].
|
||||
|
|
|
|||
|
|
@ -262,7 +262,7 @@ let flat_map f l =
|
|||
let f x = Q.Fn.apply f x in \
|
||||
let f' x = f x |> of_list in \
|
||||
of_list l |> flat_map f' |> to_list = CCList.(flat_map f l))
|
||||
*)
|
||||
*)
|
||||
|
||||
let flatten l = fold_rev ~f:(fun acc l -> append l acc) ~x:empty l
|
||||
|
||||
|
|
@ -274,7 +274,7 @@ let flatten l = fold_rev ~f:(fun acc l -> append l acc) ~x:empty l
|
|||
(*$Q
|
||||
Q.(small_list (small_list int)) (fun l -> \
|
||||
of_list l |> map ~f:of_list |> flatten |> to_list = CCList.flatten l)
|
||||
*)
|
||||
*)
|
||||
|
||||
let app funs l =
|
||||
fold_rev ~x:empty funs
|
||||
|
|
@ -452,7 +452,7 @@ let repeat n l =
|
|||
(*$Q
|
||||
Q.(pair small_int (list int)) (fun (n,l) -> \
|
||||
of_list l |> repeat n |> to_list = CCList.(repeat n l))
|
||||
*)
|
||||
*)
|
||||
|
||||
let range i j =
|
||||
let rec aux i j acc =
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue