From 873ea19b8d4bb1e8e6a21a7bcd955e4dd52d3696 Mon Sep 17 00:00:00 2001 From: Xiretza Date: Wed, 16 Dec 2020 17:55:22 +0100 Subject: [PATCH] day14/haskell: replace map-filter-enumerate with findIndices --- 2020/day14/day14.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/2020/day14/day14.hs b/2020/day14/day14.hs index 341530a..9b8b445 100644 --- a/2020/day14/day14.hs +++ b/2020/day14/day14.hs @@ -5,6 +5,7 @@ module Day14 where import AoC import Data.Bits +import Data.List import Data.Map (Map) import qualified Data.Map as M import Data.Maybe @@ -26,7 +27,7 @@ parseMaskDecl :: ReadP Mask parseMaskDecl = do string "mask = " mask <- many1 (choice $ char <$> "01X") - let extractMask c = foldl setBit zeroBits . map fst . filter ((==c) . snd) . enumerate 0 . reverse $ mask + let extractMask c = foldl setBit zeroBits . findIndices (==c) . reverse $ mask return $ Mask { set = extractMask '1' , clear = extractMask '0' , dontcare = extractMask 'X'