summaryrefslogtreecommitdiff
path: root/2024/ocaml/lib/file/read_input.ml
blob: 0f7470beb04b373e41f39bb5b91d93692110fcff (plain)
1
2
3
4
5
6
7
8
9
10
11
let rec lines_from_channel ic =
  try
    let line = input_line ic in
    line :: lines_from_channel ic
  with End_of_file -> []

let lines_from_file filename =
  let channel = open_in filename in
  let lines = lines_from_channel channel in
  close_in channel;
  lines