Jump to content

Abbreviations, automatic: Difference between revisions

→‎{{header|Haskell}}: Slightly simplified do expression for legibility
(→‎{{header|Haskell}}: Slightly simplified do expression for legibility)
Line 1,096:
=={{header|Haskell}}==
<lang haskell>import Data.List (inits, intercalate, nub, transpose)
import Control.Arrow
 
-- ABBREVIATIONS -------------------------------------------------------------
abbrevns :: [String] -> [String]
abbrevns xs =
let| nnull xs = length xs[]
in| caseotherwise n of=
let n = 0length -> []xs
_ ->in head $ dropWhile ((< n) . length) $ nub <$> transpose (inits <$> xs)
 
-- REPORTTEST --------------------------------------------------------------------
main :: IO ()
main = do
Line 1,111 ⟶ 1,112:
mapM_ putStrLn $
take 10 $
(intercalate "\t"xs .->
intercalate "\t" $
(((:) . [show . length . head . abbrevns . words), id] <*> return)[xs]) <$>
lines s</lang>
{{Out}}
9,659

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.