Textonyms: Difference between revisions
m
→{{header|Haskell}}
Line 928:
codeGroups = groupBy (on (==) snd) . sortOn snd $ encodings
textonyms = filter ((1 <) . length) codeGroups
digitCount = length . snd . head▼
[ambiguous, longer] =▼
[take 5 . flip sortBy textonyms] <*>▼
(flip . comparing <$> [length, digitCount])▼
[wa, wl] = maximum . map digitCount <$> [ambiguous, longer]▼
▲ mapM_ putStrLn $
[ "There are " ++
show (length encodings) ++
Line 943 ⟶ 938:
, show (length textonyms) ++ " digit combinations represent textonyms."
, ""
]
, "5 most ambiguous:"▼
▲ [ambiguous, longer] =
▲ [take 5 . flip sortBy textonyms] <*>
▲ (flip . comparing <$> [length, digitCount])
▲ [wa, wl] = maximum . map digitCount <$> [ambiguous, longer]
mapM_ putStrLn $
fmap (showTextonym wa) ambiguous ++
------------------------- DISPLAY --------------------------
|