implemented modifyPlayer

This commit is contained in:
Jonathan Lamothe
2019-09-25 02:28:48 -04:00
parent 625d9c616a
commit 8c8a2d52a6
2 changed files with 43 additions and 1 deletions

View File

@@ -126,7 +126,8 @@ module Mtlstats.Types (
-- ** Player Helpers
pPoints,
playerSearch,
playerSearchExact
playerSearchExact,
modifyPlayer
) where
import Control.Monad.Trans.State (StateT)
@@ -692,3 +693,18 @@ playerSearchExact sStr =
filter (match sStr) .
zip [0..]
where match sStr (_, p) = p^.pName == sStr
-- | Modifies a player with a given name
modifyPlayer
:: (Player -> Player)
-- ^ The modification function
-> String
-- ^ The player's name
-> [Player]
-- ^ The list of players to modify
-> [Player]
-- ^ The modified list
modifyPlayer f n = map
(\p -> if p^.pName == n
then f p
else p)