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 
>                       then [(a,b,c)] 
>                       else error "overdrawn customer"
> 
> except this doesn't work with things like:
> 

Right, you mean to write a list filter. List comprehensions are useful
for this:


    credit xs = [ p | p@(a,b,c) <- xs, c >= 0 ] 

or maybe:

    credit xs = filter ok xs
        where
            ok (a,b,c) = c >= 0

-- Don
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to