我了,我想通过我的客户名单迭代找到正确的客户,当我发现他们,我想要展示的任何非零INT的附加到他们。我不知道如何继续。我知道店里只有一个人的姓名记录。基本哈斯克尔:列表理解
type Name = String
type Customer = (Name,Int,Int)
type Shop = [Customer]
shop = [cust1, cust2]
cust1 = ("Steve", 321, 123) :: Customer
cust2 = ("John", 0,678) :: Customer
getName :: Customer -> Name
getName (a, b,c) = a
getNumbers :: Customer -> [Int]
getNumbers (a,b,c) = filter (/=0) [b,c]
rental:: Shop-> Name -> [Int]
rental shop' name' = map getNumbers [ x|x<-shop',getName x == name']
一如既往的完美谢谢! – John