Logo

Programming-Idioms

History of Idiom 2 > diff from v80 to v81

Edit summary for version 81 by Miltnoid:
New Caml implementation by user [Miltnoid]

Version 80

2019-09-26, 18:00:52

Version 81

2019-09-26, 19:10:31

Idiom #2 Print Hello 10 times

Loop to execute some code a constant number of times

Illustration

Idiom #2 Print Hello 10 times

Loop to execute some code a constant number of times

Illustration
Code
let rec n_hello_worlds
    (n : int)
  : unit =
  if n = 0 then
    ()
  else
    (print_endline "Hello World!";
    n_hello_worlds (n-1))

n_hello_worlds 10