0

それとも私は盲目ですか?

非常に簡単な関数で、「パターン一致の失敗: 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)
4

1 に答える 1

5

単なるタイプミスだと思います:ger_rtg最後の行で新しい関数を宣言しているためget_rtg、[] 以外のケースではパターン マッチできません。

また、私はfilterこの操作を行うために使用します:

get_rtg = filter (\(_,reg,acts,_,_,_) -> reg `elem` acts)
于 2012-12-03T15:39:18.517 に答える