Tuesday, 15 February 2011

list - How can I link these two Haskell functions together? -


I duplicate am trying to remove a certain actor because the cast list I that I have these things I I want to, but I need to link them. Two functions I need to link to createWholeActorList and removeAllActor .

  type actor = string type actor = [actor] showActors :: movie - & gt; Actor - Film Show Actors (_, A, _, _) = An Actor In Film :: Actor - & gt; Outputs a list of actors in [Actor] Actor Infilm actor = Map show actors (movies actors in these actors) CreatewallOcturist: Actor - & gt; Create ActorActactor Actor = Remove Contatat (Actor Infilm Actor) allActor :: actor - & gt; Actor - & gt; Actor removed ALLActor _ [] = [] Remove AllActor Actor (Head: Tail) | Head == actor = remover actor actor tail |   

P>

If the desired effect is the result of removing duplicates from a list, it could be easy to use (and faster code). A set is a data structure in which each item can be included only once, so to remove duplicates in a list, you can convert it to a set again and again in a set.

  Set Import Data. Set (Import) importable data. Remove Set Set Duplicate:: Ord A = & gt; [A] - & gt; [A] deleted duplicate = Setksuchi Set.fromList  

However, createActorList can be defined as

 < Code> createActorList :: actor - & gt; [Actor] createActorList = removeDuplicates CreateWholeActorList  

without createWholeActorList

  createActorList = removeDuplicates Concat actor Infilm  

No comments:

Post a Comment