Commit before potential Door refactor

This commit is contained in:
2025-10-21 19:56:48 +01:00
parent fcffbd5f43
commit 2f3a00a971
8 changed files with 118 additions and 258 deletions
+5 -4
View File
@@ -18,6 +18,7 @@ module IntMapHelp
cycleGT,
cycleLT,
invertIntMap,
invertIntMapUnique,
) where
import Control.Applicative
@@ -97,7 +98,7 @@ cycleLT :: Int -> IntMap a -> Maybe (Int, a)
cycleLT i m = lookupLT i m <|> lookupMax m
invertIntMap :: Ord a => IntMap a -> M.Map a [Int]
invertIntMap =
foldrWithKey
(\k xs -> M.insertWith (++) xs [k])
mempty
invertIntMap = foldrWithKey (\k x -> M.insertWith (++) x [k]) mempty
invertIntMapUnique :: Ord a => IntMap a -> M.Map a Int
invertIntMapUnique = foldlWithKey' (\m k x -> M.insert x k m) mempty