[Haskell-beginners] Empty list Exception

Chicão Fernandes Junior xykaumjunior at gmail.com
Sun May 24 15:13:18 EDT 2009


Hello!

I'm starting programming in haskell and I got some problems
running in GHCi (version 6.8.2) a module I've wrote.

The following ...

--The first string is the name and the second is the user ID, just for test
>
type User = (String, String, Integer)
>


> users = [("Marcelo Castro", "1234", 2),
>                        ("Joao Vicente Claudino", "1235", 2),
>                        ("Wilson Brandao", "1236", 2),
>                        ("Humberto Teixeira", "1237", 2),
>                        ("Luiz Gonzaga", "1238", 2),
>                        ("Severino Dias", "1239", 2),
>                        ("Hermeto Pascoal", "1234", 2)]
>


> checkUser ::  User -> [User] -> Bool
> checkUser user userList
>       =    if (head (filter (\userParse -> userParse == user) userList)) ==
> user
>         then True
>         else False
>
>
> userRegistration :: User -> [User] -> [User]
> userRegistration  user list
>          | checkUser user list = list
>          | not(checkUser user list) = (user : list)
>          | otherwise = []
>




-- 
____________________________________________________________________________
Francisco Borges "Chicão" Junior
..........................................................................................
http://pedepinico.blogspot.com
..........................................................................................
"Quem de boa vontade carrega o difícil, também carrega o menos difícil..."
Lao Tsé - Tao Te Ching
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20090524/10ee5b31/attachment.html


More information about the Beginners mailing list