Skip to content

Instantly share code, notes, and snippets.

@pveber
Created August 1, 2014 18:43
Show Gist options
  • Save pveber/559200fedfa0da3dbf3e to your computer and use it in GitHub Desktop.
Save pveber/559200fedfa0da3dbf3e to your computer and use it in GitHub Desktop.
Count lines with ocaml standard library
let () =
let n = ref 0 in
let ic = open_in Sys.argv.(1) in
(try
while true; do
ignore (input_line ic);
incr n
done;
assert false
with End_of_file -> ()
);
Printf.printf "%d\n" !n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment