diff options
author | tomsmeding <tom.smeding@gmail.com> | 2019-12-15 10:59:46 +0100 |
---|---|---|
committer | tomsmeding <tom.smeding@gmail.com> | 2019-12-15 10:59:46 +0100 |
commit | 92ed850443d1689d3abd9920a40c16a7940a5498 (patch) | |
tree | 50d716d26a45768d4129e716bc0b69ad8dbd7754 /2019/IntCode.hs | |
parent | 2b1e7210176d1b2a94bb09f516d5506ba1d82a51 (diff) |
Day 15
Diffstat (limited to '2019/IntCode.hs')
-rw-r--r-- | 2019/IntCode.hs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/2019/IntCode.hs b/2019/IntCode.hs index 8d180bf..1730dfd 100644 --- a/2019/IntCode.hs +++ b/2019/IntCode.hs @@ -2,7 +2,7 @@ module IntCode ( Arg(..), IC(..), mkAddr, mkImm, mkRel, parse, decode, run, unparse, - runInterruptible, runContinue, Continuation() + runInterruptible, runContinue, Continuation(), initialContinuation ) where import Control.Monad.ST @@ -134,6 +134,9 @@ runContinue (Continuation frozen ptr offset) moreinput = runST $ do Left cont -> return (Left (cont, snd res)) Right mem -> return (Right (mem, snd res)) +initialContinuation :: [Integer] -> Continuation +initialContinuation initMem = Continuation (A.listArray (0, length initMem - 1) initMem) 0 0 + runArray :: SA.STArray s Int Integer -> Int -> [Integer] -> Int -> ST s (Either Continuation [Integer], [Integer]) runArray arr ptr inp offset = do (ic, len) <- decode' arr ptr |