restructure + lecutre 07
This commit is contained in:
96 files changed
+458
-4
No files matched your search
@@ -0,0 +1,16 @@
|
||||
let rec number acc ic =
|
||||
try
|
||||
Printf.printf "%5d| %s\n" acc @@ input_line ic;
|
||||
number (acc + 1) ic
|
||||
with
|
||||
| _ -> if ic <> stdin then close_in ic else ()
|
||||
|
||||
let () =
|
||||
if Array.length Sys.argv = 1 then
|
||||
number 1 stdin
|
||||
else
|
||||
try
|
||||
number 1 @@ open_in Sys.argv.(1)
|
||||
with
|
||||
| Sys_error s -> Printf.eprintf "%s\n" s;;
|
||||
|
||||
Reference in new issue
Block a user