> type Person = (NI, Age, Balance)
> type Bank = [Person]
>
> credit :: Bank -> [Person]
> credit [(a,b,c)] = [(a,b,c)] if c >= 0
> then [(a,b,c)]
> else error "overdrawn customer"
>
> except this doesn't work with things like:
>
> credit [(1,2,3),(4,5,6
Donald Bruce Stewart wrote:
Don types faster than me. ;-)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
junkywunky:
>
> That's the thing. I want to return a list of people who are not overdrawn.
> Something like:
>
> type NI = Int
> type Age = Int
> type Balance = Int
> type Person = (NI, Age, Balance)
> type Bank = [Person]
>
> credit :: Bank -> [Person]
> credit [(a,b,c)] = [(a,b,c)] if c >= 0
That's the thing. I want to return a list of people who are not overdrawn.
Something like:
type NI = Int
type Age = Int
type Balance = Int
type Person = (NI, Age, Balance)
type Bank = [Person]
credit :: Bank -> [Person]
credit [(a,b,c)] = [(a,b,c)] if c >= 0
then [(a,b,c
junkywunky wrote:
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)]
Any help?
Thanks in advance.
The expression [(1,2,
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'
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)]
Any help?
Thanks in advance.
--
View this message in context:
http://www