It took me the afternoon but I got a LSP working

This commit is contained in:
2023-12-02 16:16:57 +01:00
parent a36a4ccbe9
commit eedd910d67
8 changed files with 35 additions and 31 deletions

View File

@@ -1,14 +1,16 @@
module Part1 where
import Commons
import Data.Char
getCalibrationValuePart :: CalibrationLine -> Char
getCalibrationValuePart (h: _) | h >= '0' && h <= '9' = h
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)]
getCalibrationValues (h: t) = ((getCalibrationValue h): (getCalibrationValues t))
getCalibrationValues [h] = [getCalibrationValue h]
getCalibrationValues (h: t) = getCalibrationValue h: getCalibrationValues t