Tidying
[advent-of-code-22.git] / advent22 / Main.hs
index 1a2e1c7eb67281b52f3c35f3a3564f77ca5d2bb3..848be83e062923f8148bd79046cfc307411d884f 100644 (file)
@@ -2,6 +2,7 @@
 
 -- import Debug.Trace
 
+
 import AoC
 import Prelude hiding (Left, Right)
 import qualified Data.Map.Strict as M
@@ -253,13 +254,16 @@ isCell r c rows = isRow && isCol && ((rows !! r) !! c) `elem` (".#" :: String)
   where isRow = r < length rows
         isCol = c < (length $ rows !! r)
 
-mkInstructions :: String -> [PathElement]
+mkInstructions, mkWalk, mkTurn :: String -> [PathElement]
 mkInstructions [] = []
-mkInstructions text@(t:ts)
+mkInstructions text@(t:_)
   | isDigit t = mkWalk text
   | otherwise = mkTurn text
+
 mkWalk text = (Forward $ read digits) : (mkInstructions remainder)
   where (digits, remainder) = span (isDigit) text
+
+mkTurn [] = []
 mkTurn (t:ts) 
   | t == 'R' = Clockwise : (mkInstructions ts)
   | t == 'L' = Anticlockwise : (mkInstructions ts)