From 520f25747d17ef651195b8fb98291b1b7a69ab1a Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Sun, 3 Jul 2016 20:27:36 +0200 Subject: ProgramStore as array for efficiency --- ABC/Program.icl | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/ABC/Program.icl b/ABC/Program.icl index 4a34ec6..28416bb 100644 --- a/ABC/Program.icl +++ b/ABC/Program.icl @@ -18,13 +18,10 @@ pc_end :: InstrId -> Bool pc_end i = i < 0 :: Location = I Instruction -:: ProgramStore :== [Location] +:: ProgramStore :== {Location} ps_get :: InstrId ProgramStore -> Instruction -ps_get 0 [I p:_] = p -ps_get _ [] = abortn "ps_get: index too large" -ps_get i [_:ps] = ps_get (i-1) ps +ps_get n p = let (I i) = p.[n] in i ps_init :: [Instruction] -> ProgramStore -ps_init [] = [] -ps_init [i:is] = [I i:ps_init is] +ps_init is = {I i \\ i <- is} -- cgit v1.2.3