Cleanup
This commit is contained in:
@@ -18,11 +18,14 @@ module IntMapHelp
|
||||
|
||||
cycleGT,
|
||||
cycleLT,
|
||||
|
||||
invertIntMap,
|
||||
) where
|
||||
|
||||
import Control.Applicative
|
||||
import Data.Aeson
|
||||
import Data.IntMap.Strict
|
||||
import qualified Data.Map.Strict as M
|
||||
import GHC.Generics
|
||||
import LensHelp
|
||||
|
||||
@@ -94,3 +97,9 @@ cycleGT i m = lookupGT i m <|> lookupMin m
|
||||
|
||||
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user