From: Neil Smith Date: Mon, 5 Dec 2022 11:38:38 +0000 (+0000) Subject: With catMaybes X-Git-Url: https://git.njae.me.uk/?p=advent-of-code-22.git;a=commitdiff_plain;h=b64a6c258a1d149fc7438ce0513530bbca0b931c With catMaybes --- diff --git a/advent05/Main.hs b/advent05/Main.hs index 727822d..21daf43 100644 --- a/advent05/Main.hs +++ b/advent05/Main.hs @@ -52,9 +52,7 @@ extractName (Crate c) = c makeWharf :: [[Maybe Crate]] -> [Int] -> Wharf makeWharf wharfLines colNames = M.fromList $ zip colNames wharfCols - where wharfCols = fmap (fmap fromJust) - $ fmap (dropWhile isNothing) - $ transpose wharfLines + where wharfCols = fmap catMaybes $ transpose wharfLines applyMoves1 :: Wharf -> [Move] -> Wharf applyMoves1 wharf moves = foldl' applyMove1 wharf moves