diff options
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 |