Allow for swapping inventory items
This commit is contained in:
@@ -15,8 +15,12 @@ module IntMapHelp
|
||||
unsafeSwapKeys,
|
||||
safeSwapKeys,
|
||||
findIndex,
|
||||
|
||||
cycleGT,
|
||||
cycleLT,
|
||||
) where
|
||||
|
||||
import Control.Applicative
|
||||
import Data.Aeson
|
||||
import Data.IntMap.Strict
|
||||
import GHC.Generics
|
||||
@@ -84,3 +88,9 @@ findIndex t = foldrWithKey f Nothing
|
||||
f k x _
|
||||
| t x = Just k
|
||||
| otherwise = Nothing
|
||||
|
||||
cycleGT :: Int -> IntMap a -> Maybe (Int, a)
|
||||
cycleGT i m = lookupGT i m <|> lookupMin m
|
||||
|
||||
cycleLT :: Int -> IntMap a -> Maybe (Int, a)
|
||||
cycleLT i m = lookupLT i m <|> lookupMax m
|
||||
|
||||
Reference in New Issue
Block a user