Clean up day 1

This commit is contained in:
Reimar 2024-12-04 16:45:57 +01:00
parent b17f36064c
commit 137c751f44
Signed by: Reimar
GPG Key ID: 93549FA07F0AE268

View File

@ -1,13 +1,13 @@
val file = TextIO.openIn "day_1.txt";
fun sortAsc (l: int list) : int list = ListMergeSort.sort (op >) l
fun sum (l: int list) : int = foldl (op +) 0 l
fun substrToInt (substr: substring) : int = valOf (Int.fromString (Substring.string substr))
val file = TextIO.openIn "day_1.txt"
val input = TextIO.inputAll file;
TextIO.closeIn file;
fun sortAsc (l: int list) : int list = ListMergeSort.sort (fn (a, b) => a > b) l
fun sum (l: int list) : int = foldl (fn (a, b) => a + b) 0 l
fun substrToInt(substr: substring) : int = valOf (Int.fromString (Substring.string substr))
val lines = String.tokens (fn (char) => char = #"\n") input
val pairs = map