From e78a1cc18a981d4be01ddb6516f8959c31c2c846 Mon Sep 17 00:00:00 2001 From: ik1g19 <ik1g19@soton.ac.uk> Date: Sat, 9 Jan 2021 21:41:48 +0000 Subject: [PATCH] minor changes --- cw/src/Challenges.hs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/cw/src/Challenges.hs b/cw/src/Challenges.hs index 9864c3d..ec8fd7a 100644 --- a/cw/src/Challenges.hs +++ b/cw/src/Challenges.hs @@ -171,7 +171,7 @@ addStrsToGrid rg gen (s:ss) = addStrsToGrid newGrid newGen ss --| returns a list of valid orientations for the |-- --| string at that position |--} validDirs :: RandGrid -> String -> Posn -> [Orientation] -validDirs rg s (x,y) = map fst $ filter (\b -> snd b == True) (zipF ( checkDir rg s (x,y) ) dirs) +validDirs rg s (x,y) = map fst $ filter ((True==) . snd) (zipF ( checkDir rg s (x,y) ) dirs) where dirs = [Forward,Back,Up,Down,UpForward,UpBack,DownForward,DownBack] @@ -330,15 +330,13 @@ closedParse :: Parser LamExpr -> Parser LamExpr closedParse p = do e <- p if free e then empty else return e -{--| finds if an expression contains free variables |-- - --| |--} +{--| finds if an expression contains free variables |--} free :: LamExpr -> Bool free (LamVar _) = True free (LamAbs x e ) = freeVar x e free (LamApp e1 e2) = free e1 && free e2 -{--| finds if a given variable is free in an expr |-- - --| |--} +{--| finds if a given variable is free in an expr |--} freeVar :: Int -> LamExpr -> Bool freeVar x (LamVar y) = not $ x == y freeVar x (LamAbs y e) | x == y = False -- GitLab