summaryrefslogtreecommitdiff
path: root/2024/OCaml/lib/file/read_input.ml
diff options
context:
space:
mode:
authorDJ O'Leary <dijitol@proton.me>2025-03-03 00:56:33 +0100
committerDJ O'Leary <dijitol@proton.me>2025-03-03 00:56:33 +0100
commite24effa8fd3574e9d396be0e1a47f101c27c0a60 (patch)
tree793896d20384facd10d925e09f8f0dd89c930cce /2024/OCaml/lib/file/read_input.ml
perf: Merge Advent of Code year specific repos
Diffstat (limited to '2024/OCaml/lib/file/read_input.ml')
-rw-r--r--2024/OCaml/lib/file/read_input.ml11
1 files changed, 11 insertions, 0 deletions
diff --git a/2024/OCaml/lib/file/read_input.ml b/2024/OCaml/lib/file/read_input.ml
new file mode 100644
index 0000000..0f7470b
--- /dev/null
+++ b/2024/OCaml/lib/file/read_input.ml
@@ -0,0 +1,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