Created
August 6, 2014 22:30
-
-
Save madmo/82c2908a43ca64cd2c44 to your computer and use it in GitHub Desktop.
Converting numbers in ocaml, the lazy way
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
open Core.Std;; | |
let read_and_convert = | |
let rec aux line = | |
match line with | |
| None -> () (* EOF *) | |
| Some txt -> | |
try print_endline (Int.to_string (Int.of_string txt)); with | |
Failure detail -> print_endline detail; ; (* End of try/with*) | |
aux (In_channel.input_line In_channel.stdin) | |
in | |
aux (In_channel.input_line In_channel.stdin) | |
;; | |
read_and_convert;; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment