From: Neil Smith Date: Sat, 6 Oct 2018 22:30:56 +0000 (+0100) Subject: Tweaked syntax layout in successors X-Git-Url: https://git.njae.me.uk/?p=summerofcode2018soln.git;a=commitdiff_plain;h=35fd88f4adee89988e8433c825f88b58a9691466 Tweaked syntax layout in successors --- diff --git a/src/task8/task8-bounded.hs b/src/task8/task8-bounded.hs index d976786..9bef74e 100644 --- a/src/task8/task8-bounded.hs +++ b/src/task8/task8-bounded.hs @@ -98,13 +98,14 @@ successors :: Int -> BoundedLawn -> Location -> (Q.Seq Neighbour) successors longCost boundedLawn (row, column) = Q.fromList $ map neighbourify neighbours where lawn = lawnMap boundedLawn neighbours = filter (\l -> l `M.member` lawn) - [(r, c) | r <- [(row - 1)..(row + 1)], - c <- [(column - 1)..(column + 1)], - r >= minR, - r <= maxR, - c >= minC, - c <= maxC, - ((r == row && c /= column) || (r /= row && c == column)) ] + [ (r, c) | r <- [(row - 1)..(row + 1)] + , c <- [(column - 1)..(column + 1)] + , r >= minR + , r <= maxR + , c >= minC + , c <= maxC + , ((r == row && c /= column) || (r /= row && c == column)) + ] neighbourify neighbour = Neighbour {stepLocation = neighbour, stepCost = scCalc neighbour} minR = minRow boundedLawn maxR = maxRow boundedLawn diff --git a/src/task8/task8.hs b/src/task8/task8.hs index b23198d..83e7e3b 100644 --- a/src/task8/task8.hs +++ b/src/task8/task8.hs @@ -82,13 +82,14 @@ candidates longCost lawn agendum closed = newCandidates successors :: Int -> Lawn -> Location -> (Q.Seq Neighbour) successors longCost lawn (row, column) = Q.fromList $ map neighbourify neighbours where neighbours = filter (\l -> l `M.member` lawn) - [(r, c) | r <- [(row - 1)..(row + 1)], - c <- [(column - 1)..(column + 1)], - r >= minR, - r <= maxR, - c >= minC, - c <= maxC, - ((r == row && c /= column) || (r /= row && c == column)) ] + [ (r, c) | r <- [(row - 1)..(row + 1)] + , c <- [(column - 1)..(column + 1)] + , r >= minR + , r <= maxR + , c >= minC + , c <= maxC + , ((r == row && c /= column) || (r /= row && c == column)) + ] neighbourify neighbour = Neighbour {stepLocation = neighbour, stepCost = scCalc neighbour} minR = minimum $ map fst $ M.keys lawn maxR = maximum $ map fst $ M.keys lawn