我试图列出一堆不属于特定银行的数字。
这是我的代码
类型
type NI = Int
type Age = Int
type Balance = Int
type Person = (NI, Age, Balance)
type Bank = [Person]
type Market = [Bank]
type Pop = [NI]
银行
rbs :: Bank
rbs = [ (1, 73, 1000)
, (2, 18, -50)
, (3, 60, 190)
, (4, 26, 300)
, (5, 24, 456)
, (6, 32, 7500)
, (7, 41, -46)
, (8, 59, -850)
, (9, 44, 348)
, (10, 66, -1000)
clyde :: Bank
clyde = [(1, 73, 240)
, (2, 18, -70)
, (23, 30, 800)
, (14, 16, 30)
, (5, 24, 800)
, (19, 81, 750)
, (17, 49, 946)
, (20, 59, -850)
, (29, 24, -348)
, (30, 76, -100)
sco :: Pop
sco = [1..20]
这是我检查 NI 是否不在银行中的代码
bankFree :: Pop -> Market -> Pop
bankFree [] x = []
bankFree x [] = error "No Banks selected"
bankFree x [[]] = []
bankFree (x:xs) [[],((n,a,b):ys)] = if x == n then bankFree (xs) [[],ys]
else x : bankFree xs [[],ys]
bankFree x [[],[]] = []
bankFree (x:xs) (((n,a,b):ys):zs) = if x == n then bankFree (xs) ((ys):zs)
else if x /= n then x : bankFree xs ((ys):zs)
else bankFree (xs) zs
如果我运行 bankFree sco [rbs,clyde] 应该显示的是 [11,12,13,15,16,18,20] 但是出现的是 [2..20]
我不知道我做错了什么以及如何继续,所以任何关于此事的帮助将不胜感激