From 7529a7ed15045fa61a6a32388f4e89fe96cbc281 Mon Sep 17 00:00:00 2001 From: Matthieu Dubuget Date: Sat, 18 Jan 2020 09:12:15 +0100 Subject: [PATCH] =?UTF-8?q?Ex=C3=A9cutable=20:=20nbr.exe?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/dune | 3 +++ bin/nbr.ml | 18 ++++++++++++++++++ dune => lib/dune | 0 nombres.ml => lib/nombres.ml | 0 4 files changed, 21 insertions(+) create mode 100644 bin/dune create mode 100644 bin/nbr.ml rename dune => lib/dune (100%) rename nombres.ml => lib/nombres.ml (100%) 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