import qualified Text.Megaparsec.Char.Lexer as L
import qualified Control.Applicative as CA
-import Data.List (foldl')
+import Data.List (foldl', foldl1')
import qualified Data.Map as M
import Data.Map ((!))
crossovers :: [Path] -> Visited
crossovers travelledPaths =
- foldl' (M.intersectionWith (+))
- (_visited $ head travelledPaths)
- (map _visited $ drop 1 travelledPaths)
+ foldl1' (M.intersectionWith (+)) $ map _visited travelledPaths
travelAllPaths :: [[Segment]] -> [Path]
travelAllPaths = map travelPath
import qualified Text.Megaparsec.Char.Lexer as L
import qualified Control.Applicative as CA
-import Data.List (foldl')
+import Data.List (foldl', foldl1')
import qualified Data.Set as S
import Linear (V2(..), (^+^), (^-^), (*^), (*^))
crossovers :: [Path] -> Visited
crossovers travelledPaths =
- foldl' S.intersection
- (_visited $ head travelledPaths)
- (map _visited $ drop 1 travelledPaths)
+ foldl1' S.intersection $ map _visited travelledPaths
travelAllPaths :: [[Segment]] -> [Path]
travelAllPaths = map travelPath