Browse Source

day14/haskell: replace map-filter-enumerate with findIndices

main
Xiretza 1 year ago
parent
commit
d99efc09fe
Signed by: xiretza
GPG Key ID: 17B78226F7139993
  1. 3
      day14/day14.hs

3
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'

Loading…
Cancel
Save