
27 May
2007
27 May
'07
8:57 a.m.
junkywunky:
type Person = (NI, Age, Balance) type Bank = [Person]
credit :: Bank -> [Person] credit [(a,b,c)] = [(a,b,c)]
This code works when I type in:
credit [(1,2,3)]
but doesn't work when I type in:
credit [(1,2,3),(4,5,6)]
You're pattern matching in 'credit' on a list of a single element. Perhaps you mean to write: credit :: Bank -> [Person] credit x = x or perhaps return just the first element of the list: credit [] = [] credit (x:xs) = x You might want to start with one of the tutorials on Haskell programming listed on haskell.org. The wikibook is quite a good start. -- Don