這是我的代碼有:過濾Haskell的列表
data Review = Review { artiest :: String,
score :: Integer,
tour :: Tour,
datum :: String,
plaats :: String,
soortLocatie :: Locatie,
topSongs :: [String]
} deriving (Eq, Ord, Show)
getBestLoc [] beste = beste
getBestLoc (x:xs) beste
| (score x) > beste = getBestLoc xs (score x)
| otherwise = getBestLoc xs beste
我試圖做的是讓評審白衣的最好成績,但我想返回的Locatie。現在我得到最好的成績。我該如何解決這個問題?
編輯
因此,這是新的功能,我想
tester :: [Review] -> Locatie
tester = loc
where mxscr = maximumBy (compare `on` score)
loc = map soortLocatie mxscr
這有效,但現在我得到完整的審查,我只想要返回Locatie。 – josvankamp
@brampieOO然後將'soortLocatie'應用於'getBestLoc'的輸出。 –
@Chris Taylor當我將點評更改爲不起作用的點位圖 – josvankamp