Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let () =
- let x = !(ref 2) in
- let y = !(ref 3) in
- let z = !(ref (-4)) in
- assert (x + y = 5);
- assert (x + z = -2);
- assert (z + y = -1);
- assert (x + y + z = 1);
- assert (x - y = -1);
- assert (x - z = 6);
- assert (z - y = -7);
- assert (x + y - z = 9);
- assert (x - y + z = -5);
- assert (x - y - z = 3);
- let start = Unix.gettimeofday () in
- let rec loop x y =
- let x = x - y in
- let x = x - y in
- let x = x - y in
- let x = x - y in
- let x = x - y in
- let x = x - y in
- let x = x - y in
- let x = x - y in
- if x < 1000000000 then
- loop x y
- in
- loop 1 (-1);
- Printf.printf "%f\n" (Unix.gettimeofday () -. start);
- let start = Unix.gettimeofday () in
- let rec loop x y =
- let x = x + y in
- let x = x + y in
- let x = x + y in
- let x = x + y in
- let x = x + y in
- let x = x + y in
- let x = x + y in
- let x = x + y in
- if x < 1000000000 then
- loop x y
- in
- loop 1 1;
- Printf.printf "%f\n" (Unix.gettimeofday () -. start)
Add Comment
Please, Sign In to add comment