split out some map stuff
This commit is contained in:
parent
fbf5324a9d
commit
bf1c371137
|
|
@ -30,7 +30,8 @@ next :: Algorithm -> Image -> Image
|
||||||
next algo (Img def diff) = Img (newDefault algo def) newDiff where
|
next algo (Img def diff) = Img (newDefault algo def) newDiff where
|
||||||
nonDefault = foldr (\(x,y) -> insertManyWith (++) (neighs x y)) M.empty diff
|
nonDefault = foldr (\(x,y) -> insertManyWith (++) (neighs x y)) M.empty diff
|
||||||
neighs x y = map (\i -> ((x-1 + i `mod` 3, y-1 + i `div` 3), [i])) [0..8]
|
neighs x y = map (\i -> ((x-1 + i `mod` 3, y-1 + i `div` 3), [i])) [0..8]
|
||||||
calcNonDef = M.filter (/= newDefault algo def) $ M.map (\ns -> algo A.! binToDec (nonDefToNum ns)) nonDefault
|
known = M.map (\ns -> algo A.! binToDec (nonDefToNum ns)) nonDefault
|
||||||
|
calcNonDef = M.filter (/= newDefault algo def) known
|
||||||
nonDefToNum ns = map (\i -> if i `elem` ns then not def else def) [0..8]
|
nonDefToNum ns = map (\i -> if i `elem` ns then not def else def) [0..8]
|
||||||
newDiff = M.keys calcNonDef
|
newDiff = M.keys calcNonDef
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue