Play with syntax
This commit is contained in:
@@ -16,4 +16,4 @@ parse = do done <- isEOF
|
||||
then return []
|
||||
else do line <- parseLine
|
||||
doc <- parse
|
||||
return (line:doc)
|
||||
return $ line: doc
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user