gameServer/Utils.hs
changeset 10351 0eff41e9f63f
parent 10063 52e293f14977
child 10460 8dcea9087d75
--- a/gameServer/Utils.hs	Fri Jul 04 22:45:59 2014 +0400
+++ b/gameServer/Utils.hs	Sat Jul 05 15:28:32 2014 +0400
@@ -185,4 +185,13 @@
 loc = id
 
 maybeNick :: Maybe ClientInfo -> B.ByteString
-maybeNick = fromMaybe "[empty]" . liftM nick
+maybeNick = fromMaybe "[]" . liftM nick
+
+-- borrowed from Data.List, just more general in types
+deleteBy2                :: (a -> b -> Bool) -> a -> [b] -> [b]
+deleteBy2 _  _ []        = []
+deleteBy2 eq x (y:ys)    = if x `eq` y then ys else y : deleteBy2 eq x ys
+
+deleteFirstsBy2          :: (a -> b -> Bool) -> [a] -> [b] -> [a]
+deleteFirstsBy2 eq       =  foldl (flip (deleteBy2 (flip eq)))
+