Created
September 7, 2015 09:43
-
-
Save lindig/e1afdf385af1ba9cab35 to your computer and use it in GitHub Desktop.
hello.ml - discussion about using open in OCaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let rec join = function | |
| [] -> "" | |
| [x] -> x | |
| [x;y] -> x^" and "^y | |
| x::xs -> x ^ ", " ^ join xs | |
let main () = | |
let argv = Array.to_list Sys.argv in | |
let args = List.tl argv in | |
match args with | |
| [] -> Printf.printf "Hello, world!\n" | |
| names -> Printf.printf "Hello, %s!\n" (join names) | |
let () = main () | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment