Textonyms: Difference between revisions
m
→{{header|Haskell}}
Line 904:
<lang haskell>{-# LANGUAGE TupleSections #-}
import Data.List (groupBy, maximum, sortBy, sortOn)
import qualified Data.Map as M
import Data.Maybe (mapMaybe)
Line 938:
justifyRight n c = (drop . length) <*> (replicate n c ++)
firstColWidth :: [[(String, String)]] -> Int
main :: IO ()
main = do
Line 949 ⟶ 950:
ambiguous = take 5 $ sortBy (flip (comparing length)) textonyms
longer = take 5 $ sortBy (flip (comparing (length . fst . head))) textonyms
▲ colWidth xs = maximum $ map (length . fst . head) xs
▲ [wa, wl] = colWidth <$> [ambiguous, longer]
mapM_ putStrLn $
[ "There are " ++
|