lec 05 notes

This commit is contained in:
SowinskiBraeden committed 2026-02-05 11:37:06 -08:00
1 parent 9d6617daee
commit 2da8e0df6c
10 files changed
+249

No files matched your search

+16
View File
@@ -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;;