我想列出一些不屬於特定銀行的號碼。列出沒有賬戶的國家保險號碼
這裏是我的代碼
類型
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 [rb s,clyde]應該顯示的是[11,12,13,15,16,18,20]但是出現的是[2..20]
我不知道我在做什麼錯,如何進行,所以任何關於此事的幫助將不勝感激
那麼「國民保險號碼」的號碼是? – pigworker
@pigworker在這種情況下,它們應該是Int的,所以NI = 1,NI = 2等等。 – Zantengetsu
@pigworker:至少根據Neil和他發出的課程作業。 – Zantengetsu