Frage

or am i just blind?

Very easy easy function, throws "Pattern match failure: get_rtg db"

type Movie       = (Title,Regisseur,MainActors,ReleaseDate,Genre,SalesPrice)
type Title       = String
type Regisseur   = String
type Actor       = String
type MainActors  = [Actor]
type ReleaseDate = Int
data Genre       = Thriller | Fantasy | ScienceFiction | Comedy deriving (Eq,Ord,Show)
type SalesPrice  = Int
type Database    = [Movie]


-- gets all entrys which have a Regisseur, who is in MainActors at the same time
get_rtg :: Database -> [(Regisseur,Title,Genre)]
get_rtg []                             = []
ger_rtg ((ti,reg,acts,rel,gen,sal):xs) = if (isInfixOf [reg] acts) then ([(reg,ti,gen)] ++ (get_rtg xs)) else (get_rtg xs)
War es hilfreich?

Lösung

I suppose it's just a typo: ger_rtg at the last line declares a new function, so get_rtg can't be pattern matched now in a non-[] case.

Also, I would use filter to do this operation:

get_rtg = filter (\(_,reg,acts,_,_,_) -> reg `elem` acts)
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top