Compare commits
2 Commits
1569132c6c
...
8ea4705c17
Author | SHA1 | Date | |
---|---|---|---|
|
8ea4705c17 | ||
|
7529a7ed15 |
@ -7,3 +7,7 @@ Some references:
|
||||
- https://leconjugueur.lefigaro.fr/frlesnombres.php
|
||||
- https://www.miakinen.net/vrac/nombres
|
||||
- https://www.dcode.fr/ecriture-nombre-lettres
|
||||
|
||||
|
||||
Provided as a 1-function library, and a basic command-line utility (`nbr` — will
|
||||
certainly be renamed to something longer and less likely to name clash).
|
||||
|
4
bin/dune
Normal file
4
bin/dune
Normal file
@ -0,0 +1,4 @@
|
||||
(executable
|
||||
(name nbr)
|
||||
(public_name nbr)
|
||||
(libraries nombres))
|
18
bin/nbr.ml
Normal file
18
bin/nbr.ml
Normal file
@ -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 ()
|
Loading…
x
Reference in New Issue
Block a user