From 35fd88f4adee89988e8433c825f88b58a9691466 Mon Sep 17 00:00:00 2001 From: Neil Smith Date: Sat, 6 Oct 2018 23:30:56 +0100 Subject: [PATCH] Tweaked syntax layout in successors --- src/task8/task8-bounded.hs | 15 ++++++++------- src/task8/task8.hs | 15 ++++++++------- 2 files changed, 16 insertions(+), 14 deletions(-) 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 -- 2.34.1