Skip to content

Instantly share code, notes, and snippets.

@madmo
Created August 6, 2014 22:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save madmo/82c2908a43ca64cd2c44 to your computer and use it in GitHub Desktop.
Save madmo/82c2908a43ca64cd2c44 to your computer and use it in GitHub Desktop.
Converting numbers in ocaml, the lazy way
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