New patches from Fedora.
[fedora-mingw.git] / ocaml / test4.ml
1 (* From: http://www.ocaml-tutorial.org/the_structure_of_ocaml_programs *)
2
3 let () =
4   Random.self_init ();
5   Graphics.open_graph " 640x480";
6
7   let rec iterate r x_init i =
8     if i = 1 then x_init
9     else
10       let x = iterate r x_init (i-1) in
11       r *. x *. (1.0 -. x)
12   in
13
14   for x = 0 to 639 do
15     let r = 4.0 *. (float_of_int x) /. 640.0 in
16     for i = 0 to 39 do
17       let x_init = Random.float 1.0 in
18       let x_final = iterate r x_init 500 in
19       let y = int_of_float (x_final *. 480.) in
20       Graphics.plot x y
21     done
22   done;
23
24   ignore (read_line ())