|
|
|
|
|
by bazzargh
4194 days ago
|
|
all that, plus, re the question at the end of the article about chooseBest: chooseBest ch ws = maximumBy (compare `on` (\w -> M.findWithDefault 0 w ws))
(S.toList ch)
this is closer to what's in Norvig's article - a single pass over the elements of 'ch', taking the one whose entry in the 'ws' set has the highest count - treating words not in the set as having a count of 0. No sort required. (maximumBy is from Data.List, on is from Data.Function) |
|