我的代码中有这些数据
data Client = aClient {name::String,alcohol::Int,friends::[Client]} deriving (Show)
我正在尝试制作一个取决于客户休息时间的功能,它会增加酒精耐受性。
letgo :: Client -> Integer -> Client
letgo (aClient _ alcohol _) hours
我需要知道如何根据情况更新数据中的酒精字段。
data Client = Client {name::String,alcohol::Int,friends::[Client]} deriving (Show)
letgo :: Client -> Integer -> Client
letgo client@(Client name alcohol friends) hours
| sufficientRest hours = Client name (increaseResistance alcohol) friends
| otherwise = client
sufficientRest :: Integer -> Bool
increaseResistance :: Int -> Int
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句