Jump to content

[Resolvido] Elementos repetidos numa lista


joaolliveira

Recommended Posts

data Auction = Auction {
actid :: Int,
actowner :: String,
actdesc :: String,
actvalue :: Int,
actbidder :: String
} deriving (Show,Eq,Ord) 

Tenho este data Type , e quero fazer uma função que percorra uma lista de Auction, para ver se existem actid repetidos. Caso exista é devolvido True

repetidos :: [Auction] -> Bool

eu tinha feito uma coisa deste género, mas isto só funciona para o primeiro da lista....



auctioncompare :: [Auction] -> Bool
auctioncompare [] = False
auctioncompare ((Auction a b c d e):(Auction q w i r t):hs) = if (a==q) then True else auctioncompare((Auction a b c d e):hs)


Algém tem ideia de como acabar isto?

Obrigado desde já

Edit: Já está resolvido!

Edited by Baderous
geshi
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.