From ec0b71b4cf39d530cbadce01ad30236d85930527 Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Wed, 23 Jul 2014 08:25:26 +1000 Subject: Fixed list item selection bug --- src/Grasp/Interpreter.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Grasp/Interpreter.hs b/src/Grasp/Interpreter.hs index 3e822ac..ad9215a 100644 --- a/src/Grasp/Interpreter.hs +++ b/src/Grasp/Interpreter.hs @@ -131,7 +131,7 @@ targetLNodes g = map (\(_,x,_) -> (x, fromJust (Graph.lab g x)) ) updateIP :: IP -> [LNode String] -> IO IP updateIP _ [] = return [] updateIP ip next = - getStdRandom (randomR (0,length next)) >>= + getStdRandom (randomR (0,length next - 1)) >>= (\x -> return ((next !! x):(tail ip)) ) @@ -146,7 +146,7 @@ setI g ip = do g' <- case inL of [] -> return g - _ -> (getStdRandom (randomR (0,length inL))) >>= + _ -> (getStdRandom (randomR (0,length inL - 1))) >>= (\x -> return (foldl' (\gr n -> reLabel gr n (inL !! x)) g outN) ) ip' <- updateIP ip nextLN @@ -343,7 +343,7 @@ putcI g ip = do fhL = targetLabels g (getByLabel "fh" edges) nextLN = targetLNodes g (getByLabel "next" edges) - r <- getStdRandom (randomR (0, length inL)) + r <- getStdRandom (randomR (0, length inL - 1)) c <- case inL of x | length x == 0 -> -- cgit