Remove cross-deps

This commit is contained in:
Jacques-Pascal Deplaix 2017-12-01 09:21:54 +00:00
parent ffba89de53
commit a01a81667b
5 changed files with 23 additions and 13 deletions

View file

@ -7,10 +7,10 @@ type 'a t = 'a -> 'a -> bool
let poly = Pervasives.(=)
let int : int t = CCInt.equal
let string : string t = CCString.equal
let bool : bool t = CCBool.equal
let float : float t = CCFloat.equal
let int : int t = Pervasives.(=)
let string : string t = Pervasives.(=)
let bool : bool t = Pervasives.(=)
let float : float t = Pervasives.(=)
let unit () () = true
let rec list f l1 l2 = match l1, l2 with

View file

@ -77,7 +77,8 @@ let floor_div a n =
let rem a n =
let y = a mod n in
if not (CCBool.equal (y < 0) (n < 0)) && y <> 0 then
let bool_neq (a : bool) b = Pervasives.(<>) a b in
if bool_neq (y < 0) (n < 0) && y <> 0 then
y + n
else
y

View file

@ -81,13 +81,15 @@ let fail_ ~err st msg =
let b = (st.lnum, st.cnum, None) :: st.branch in
err (ParseError (b, msg))
let char_eq (a : char) b = Pervasives.(=) a b
let next st ~ok ~err =
if st.i = String.length st.str
then fail_ st ~err (const_ "unexpected end of input")
else (
let c = st.str.[st.i] in
st.i <- st.i + 1;
if CCChar.equal c '\n'
if char_eq c '\n'
then (st.lnum <- st.lnum + 1; st.cnum <- 1)
else st.cnum <- st.cnum + 1;
ok c
@ -146,7 +148,7 @@ let char c =
let msg = Printf.sprintf "expected '%c'" c in
fun st ~ok ~err ->
next st ~err
~ok:(fun c' -> if CCChar.equal c c' then ok c else fail_ ~err st (const_ msg))
~ok:(fun c' -> if char_eq c c' then ok c else fail_ ~err st (const_ msg))
let char_if p st ~ok ~err =
next st ~err
@ -161,10 +163,12 @@ let chars_if p st ~ok ~err:_ =
while not (is_done st) && p (cur st) do junk_ st; incr len done;
ok (String.sub st.str i !len)
let string_is_empty (s : string) = Pervasives.(=) s ""
let chars1_if p st ~ok ~err =
chars_if p st ~err
~ok:(fun s ->
if CCString.is_empty s
if string_is_empty s
then fail_ ~err st (const_ "unexpected sequence of chars")
else ok s)
@ -231,7 +235,7 @@ let string s st ~ok ~err =
else
next st ~err
~ok:(fun c ->
if CCChar.equal c s.[i]
if char_eq c s.[i]
then check (i+1)
else fail_ ~err st (fun () -> Printf.sprintf "expected \"%s\"" s))
in
@ -386,7 +390,7 @@ module U = struct
skip_white <* string stop
let int =
chars1_if (fun c -> is_num c || CCChar.equal c '-')
chars1_if (fun c -> is_num c || char_eq c '-')
>>= fun s ->
try return (int_of_string s)
with Failure _ -> fail "expected an int"

View file

@ -108,6 +108,7 @@ let _diff_list ~last l =
in
diff_list [] l
let int_cmp (a : int) b = Pervasives.compare a b
(* Partition of an int into [len] integers uniformly.
We first sample (len-1) points from the set {1,..i-1} without replacement.
@ -118,7 +119,7 @@ let _diff_list ~last l =
let split_list i ~len st =
if len <= 1 then invalid_arg "Random.split_list";
if i >= len then
let xs = sample_without_replacement ~compare:CCInt.compare (len-1) (int_range 1 (i-1)) st in
let xs = sample_without_replacement ~compare:int_cmp (len-1) (int_range 1 (i-1)) st in
_diff_list ( 0::xs ) ~last:i
else
None
@ -221,7 +222,8 @@ let uniformity_test ?(size_hint=10) k rng st =
let confidence = 4. in
let std = confidence *. (sqrt (kf *. variance)) in
let predicate _key n acc =
CCFloat.Infix.(acc && abs_float (average -. float_of_int n) < std) in
let (<) (a : float) b = Pervasives.(<) a b in
acc && abs_float (average -. float_of_int n) < std in
Hashtbl.fold predicate histogram true
(*$T split_list

View file

@ -6,7 +6,10 @@
type job =
| Job : float * (unit -> 'a) -> job
open CCFloat.Infix
let (<=) (a : float) b = Pervasives.(<=) a b
let (>=) (a : float) b = Pervasives.(>=) a b
let (<) (a : float) b = Pervasives.(<) a b
let (>) (a : float) b = Pervasives.(>) a b
module TaskHeap = CCHeap.Make(struct
type t = job