Day 9: I like error more than custom exceptions

This commit is contained in:
shu 2019-12-11 20:45:43 +01:00
parent 345d628347
commit f274db5fbe

View File

@ -46,12 +46,6 @@ data TuringMachine =
}
deriving (Show)
data IntcodeExcept =
UnknownOpCodeException
deriving (Show)
instance Exception IntcodeExcept
tapePreprocess :: Vector Integer -> Vector Integer
tapePreprocess t = (V.++) t $ V.replicate 105 0
@ -124,7 +118,7 @@ step tm =
else 0)
"9" -> tmn {pointerOffset = pointerOffset tm + (params ! 0)}
"99" -> tm {state = Halt}
_ -> throw UnknownOpCodeException
_ -> error "Illegal Opcode."
where
pNew = pointer tm + opLength (tape tm ! fromInteger (pointer tm))
tmn = tm {pointer = pNew}