小编Tha*_*age的帖子

从具有2个以上元素的元组列表中检索元素(Haskell)

我是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)

haskell tuples list-comprehension list nested-lists

4
推荐指数
2
解决办法
520
查看次数

标签 统计

haskell ×1

list ×1

list-comprehension ×1

nested-lists ×1

tuples ×1