Commit before potential Door refactor
This commit is contained in:
+5
-4
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user