Created
August 1, 2014 18:43
-
-
Save pveber/559200fedfa0da3dbf3e to your computer and use it in GitHub Desktop.
Count lines with ocaml standard library
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 () = | |
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