我是Haskell的新手,在这种情况下需要一些帮助.我有以下清单
-- create a type for bank account
type AcNo = String
type Name = String
type City = String
type Amnt = Int
type AcInfo = [(AcNo, Name, City, Amnt)]
-- function to get the data of bank accounts to a list of tuples
bankAccounts :: AcInfo
bankAccounts = [("oo1", "Sahan", "Colomb", 100),("002", "John", "Jafna", 200)]
Run Code Online (Sandbox Code Playgroud)
我的要求是获得与帐号相对应的金额,例如,对于001,它应该给出100.
我写的功能就是这个
--Function to check the balance of a person
checkBalance :: bankAccounts -> AcNo -> Amnt
checkBalance dbase number = Amnt|(AcNo, Name, …Run Code Online (Sandbox Code Playgroud)