day14/haskell: replace map-filter-enumerate with findIndices
This commit is contained in:
parent
6dee5caf29
commit
873ea19b8d
1 changed files with 2 additions and 1 deletions
|
@ -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'
|
||||
|
|
Loading…
Reference in a new issue