Advice on a program.

"Douglas Lewit [email protected] [ocaml_beginners]" <[email protected]> Sun, 14 Feb 2016 20:18:50 -0600
Newsgroups gmane.comp.lang.ocaml.beginners
Message-ID <CAM0XMJQQocDpaax8OCiPRwW8gTTZ_02yBxiZkKq7fWmq-v8r1g@mail.gmail.com>
Hi everyone,

I need advice on a program.  I want the pause ( Thread.delay <float> )
after each number, but instead I'm getting the pause after each line.

What am I doing wrong?

Thanks!

Best,

Douglas.

(* Ocaml program to generate a simple multiplication table or table of
products.

 * A great example of imperative programming in Ocaml. *)


open Printf ;;


print_string "Enter a positive integer: " ;;


let n = read_int ( ) ;;


let createMatrix i j initial = let matrix = Array.make i ( Array.make j
initial ) in

for n = 0 to i - 1 do

matrix.(n) <- Array.make j initial ;

done ;

matrix ;;


let arr = createMatrix n n 0 ;;  (* Initialize the 2-dimensional array
needed to solve this problem. *)


for j = 0 to n - 1 do

arr.(0).(j) <- j + 1;

done ;;


for i = 0 to n - 1 do

arr.(i).(0) <- i + 1;

done ;;


for i = 1 to n - 1 do

for j = 1 to n - 1 do

arr.(i).(j) <- arr.(i).(0) * arr.(0).(j) ;

done ;

done ;;


print_newline ( ) ;;


for i = 0 to n - 1 do

for j = 0 to n - 1 do

printf "%5i" arr.(i).(j) ;

Thread.delay 0.012 ;

done ;

print_newline ( ) ;

done ;;


print_newline ( ) ;;