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
symb = L.symbol sc
comma = symb ","
-wiresP = some pathP
+wiresP = many pathP
pathP = segmentP `sepBy1` comma
segmentP = segmentify <$> directionP <*> integer