diff --git a/bin/dune b/bin/dune new file mode 100644 index 0000000..d590357 --- /dev/null +++ b/bin/dune @@ -0,0 +1,3 @@ +(executable + (name nbr) + (libraries nombres)) diff --git a/bin/nbr.ml b/bin/nbr.ml new file mode 100644 index 0000000..1dcef5f --- /dev/null +++ b/bin/nbr.ml @@ -0,0 +1,18 @@ +let rec parse_and_print () = + print_string "Entier ? > "; + flush stdout; + input_line stdin |> function + | "q" | "Q" -> () + | "h" | "?" | "H" -> + print_endline "Je n'accepte que des entiers. 'q' ou 'Q' pour quitter."; + flush stdout; + parse_and_print () + | str -> + str |> int_of_string + |> (fun i -> + match i with + | i -> i |> Nombres.nombre_of_int |> print_endline + | exception _ -> ()) + |> parse_and_print + +let () = parse_and_print () diff --git a/dune b/lib/dune similarity index 100% rename from dune rename to lib/dune diff --git a/nombres.ml b/lib/nombres.ml similarity index 100% rename from nombres.ml rename to lib/nombres.ml