Play with syntax

This commit is contained in:
2023-12-04 19:05:20 +01:00
parent e746e22b0b
commit 53cad097f8
15 changed files with 27 additions and 26 deletions

View File

@@ -16,4 +16,4 @@ parse = do done <- isEOF
then return []
else do line <- parseLine
doc <- parse
return (line:doc)
return $ line: doc

View File

@@ -6,7 +6,7 @@ import Part2
main = do doc <- parse
let part1Res = sum (Part1.getCalibrationValues doc)
let part1Res = sum $ Part1.getCalibrationValues doc
print part1Res
let part2Res = sum (Part2.getCalibrationValues doc)
let part2Res = sum $ Part2.getCalibrationValues doc
print part2Res

View File

@@ -9,7 +9,7 @@ getCalibrationValuePart (h: _) | isDigit h = h
getCalibrationValuePart (_: t) = getCalibrationValuePart t
getCalibrationValue :: CalibrationLine -> Integer
getCalibrationValue line = read [getCalibrationValuePart line, getCalibrationValuePart (reverse line)]
getCalibrationValue line = read [getCalibrationValuePart line, getCalibrationValuePart . reverse $ line]
getCalibrationValues :: CalibrationDocument -> [Integer]
getCalibrationValues [h] = [getCalibrationValue h]

View File

@@ -32,7 +32,7 @@ getCalibrationValueRight (h: _) | isDigit h = h
getCalibrationValueRight (_: t) = getCalibrationValueRight t
getCalibrationValue :: CalibrationLine -> Integer
getCalibrationValue line = read [getCalibrationValueLeft line, getCalibrationValueRight (reverse line)]
getCalibrationValue line = read [getCalibrationValueLeft line, getCalibrationValueRight . reverse $ line]
getCalibrationValues :: CalibrationDocument -> [Integer]
getCalibrationValues [h] = [getCalibrationValue h]