aoc2022/lib/utils.ml

12 lines
277 B
OCaml
Raw Normal View History

2022-12-01 23:45:12 +01:00
let read_file name =
let ic = open_in name in
let try_read () =
try Some (input_line ic)
with End_of_file -> None in
let rec aux acc =
match try_read () with
| Some s -> aux (s::acc)
| None -> close_in ic; acc in
aux []