better split in day 6
This commit is contained in:
parent
52f550dc86
commit
2dc820fc5b
11
day6.hs
11
day6.hs
@ -16,10 +16,7 @@ match as bs = (sort . nub) $ filter (`elem` bs) as
|
||||
|
||||
split :: Eq a => a -> [a] -> [[a]]
|
||||
split _ [] = []
|
||||
split v as = split' v as [] []
|
||||
|
||||
split' :: Eq a => a -> [a] -> [a] -> [[a]] -> [[a]]
|
||||
split' _ [] a as = as ++ [a]
|
||||
split' v (b:bs) a as
|
||||
| b == v = split' v bs [] (as ++ [a])
|
||||
| otherwise = split' v bs (a ++ [b]) as
|
||||
split d as = chunk : (split d rest)
|
||||
where
|
||||
chunk = takeWhile (/= d) as
|
||||
rest = drop 1 $ dropWhile (/= d) as
|
||||
|
Loading…
Reference in New Issue
Block a user