2020-01-18 08:12:15 +00:00
|
|
|
let rec parse_and_print () =
|
2021-05-24 09:02:34 +00:00
|
|
|
print_string "Entier (Ou [Q]uitter [H]elp) ? > ";
|
2020-01-18 08:12:15 +00:00
|
|
|
flush stdout;
|
|
|
|
input_line stdin |> function
|
|
|
|
| "q" | "Q" -> ()
|
|
|
|
| "h" | "?" | "H" ->
|
2022-04-10 09:58:17 +00:00
|
|
|
print_endline
|
|
|
|
"Je n'accepte que des entiers positifs. Et pas trop grands…\n\
|
|
|
|
'q' ou 'Q' pour quitter.";
|
2020-01-18 08:12:15 +00:00
|
|
|
flush stdout;
|
|
|
|
parse_and_print ()
|
|
|
|
| str ->
|
|
|
|
str |> int_of_string
|
|
|
|
|> (fun i ->
|
|
|
|
match i with
|
2022-04-10 09:58:17 +00:00
|
|
|
| i -> i |> Nombres.nombre |> print_endline
|
2020-01-18 08:12:15 +00:00
|
|
|
| exception _ -> ())
|
|
|
|
|> parse_and_print
|
|
|
|
|
|
|
|
let () = parse_and_print ()
|