From: acondolu Date: Sat, 15 Jul 2017 14:47:50 +0000 (+0200) Subject: Code clean-up X-Git-Tag: weak-reduction-separation~25 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=4ca74b77536dcd58dfff5e09996b6d8bb117c60a;p=fireball-separation.git Code clean-up (cherry picked from commit 8fcb433208ce608350ea554dd1d92fa5a45fd463) --- diff --git a/ocaml/Makefile b/ocaml/Makefile index 430f159..138cc99 100644 --- a/ocaml/Makefile +++ b/ocaml/Makefile @@ -3,7 +3,6 @@ LIB = unix.cmxa str.cmxa UTILS = util.cmx console.cmx listx.cmx pure.cmx num.cmx parser.cmx all: a.out test4.out - # test.out run: test4.out bash run @@ -11,9 +10,6 @@ run: test4.out a.out: $(UTILS) lambda4.cmx problems.cmx $(OCAMLC) -o a.out $(LIB) $^ -# test.out: $(UTILS) lambda3.cmx test1.ml -# $(OCAMLC) -o test.out $(LIB) $^ -# test4.out: $(UTILS) lambda4.cmx test.ml $(OCAMLC) -o test4.out $(LIB) $^ diff --git a/ocaml/test.ml b/ocaml/test.ml index da6dbda..3b6d904 100644 --- a/ocaml/test.ml +++ b/ocaml/test.ml @@ -12,24 +12,14 @@ let acaso2 l1 l2 = if n >= n1 then List.nth l2 (n - n1) else List.nth l1 n ;; -let rec take l n = +(* let rec take l n = if n = 0 then [] else match l with | [] -> [] | x::xs -> x :: (take xs (n-1)) -;; - -let test3 n vars = - let rec aux n inerts lams = - if n = 0 then take (Util.sort_uniq inerts) 5 - else let inerts, lams = if Random.int 2 = 0 - then inerts, ("(" ^ acaso vars ^ ". " ^ acaso2 inerts lams ^ ")") :: lams - else ("(" ^ acaso inerts ^ " " ^ acaso2 inerts lams^ ")") :: inerts, lams - in aux (n-1) inerts lams - in aux (2*n) vars [] -;; +;; *) -let test4 n vars = +let gen n vars = let rec take' l n = if n = 0 then [], [] else match l with @@ -47,17 +37,12 @@ let test4 n vars = let rec repeat f n = - prerr_endline "\n*************************** NEW TEST ***************************"; + prerr_endline "\n########################### NEW TEST ###########################"; f () ; if n > 0 then repeat f (n-1) ;; -(* let call_main3 tms = - let _ = ( - List.iter prerr_endline tms; prerr_newline (); - ) in Lambda3.main [Lambda3.magic tms ["*"]] -;; *) -let call_main4 div convs nums = +let solve div convs nums = let p = String.concat "\n" ( "$! randomly generated test" :: ("D " ^ div) :: @@ -74,16 +59,9 @@ let main = let complex = 200 in let vars = ["x"; "y"; "z"; "v" ; "w"; "a"; "b"; "c"] in - (* let open Parser in *) - - (* if three then repeat (fun _ -> - let tms = test3 complex vars in - call_main3 tms - ) num - else *) repeat (fun _ -> - let div, (conv, nums) = test4 complex vars in - call_main4 div conv nums + let div, (conv, nums) = gen complex vars in + solve div conv nums ) num ; diff --git a/ocaml/test1.ml b/ocaml/test1.ml deleted file mode 100644 index 424ec72..0000000 --- a/ocaml/test1.ml +++ /dev/null @@ -1,73 +0,0 @@ - - -let acaso l = - let n = Random.int (List.length l) in - List.nth l n -;; - -let acaso2 l1 l2 = - let n1 = List.length l1 in - let n = Random.int (n1 + List.length l2) in - if n >= n1 then List.nth l2 (n - n1) else List.nth l1 n -;; - -let rec take l n = - if n = 0 then [] - else match l with - | [] -> [] - | x::xs -> x :: (take xs (n-1)) -;; - -let test1 n vars = - let rec aux n l = - if n = 0 - then take (Util.sort_uniq l) 3 - else aux (n-1) (("(" ^ (acaso l) ^ " " ^ (acaso l) ^ ")") :: l) - in aux n vars -;; - -let test2 n vars = - let rec aux n ins lams = - if n = 0 then take (Util.sort_uniq ins) 5 - else let ins, lams = if Random.int 2 = 0 - then ins, ("(" ^ acaso vars ^ ". " ^ acaso2 ins lams ^ ")") :: lams - else ("(" ^ acaso ins ^ " " ^ acaso2 ins lams^ ")") :: ins, lams - in aux (n-1) ins lams - in aux (2*n) vars [] -;; - - -let rec repeat f n = f () ; if n > 0 then repeat f (n-1);; - -let call_main tms = - let _ = ( - prerr_endline "\n*************************** NEW TEST ***************************"; - List.iter prerr_endline tms; prerr_endline ""; - ) in Lambda3.main [Lambda3.magic tms ["*"]] -;; - -let main = - Random.self_init (); - (*Random.init 1000;*) - let num = 100 in - let complex = 200 in - let vars = ["x"; "y"; "z"; "v" ; "w"; "a"; "b"; "c"] in - - let open Parser in - let open Lambda3 in - - (* test1 *) - repeat (fun _ -> - let tms = test1 complex vars in - call_main tms - ) num - ; - - (* test2 *) - repeat (fun _ -> - call_main (test2 complex vars) - ) num - ; - - prerr_endline "\n---- ALL TESTS COMPLETED ----" -;;