Abbreviations, automatic: Difference between revisions
Content deleted Content added
→{{header|Haskell}}: Simplified by using transpose . (inits <$>) |
→{{header|Haskell}}: Generalised beyond the specific case of 7 strings |
||
Line 282:
<lang haskell>import Data.List (inits, nub, transpose)
abbrevns :: [String] ->
abbrevns xs =
let lng = length xs
take 1 . dropWhile ((< 7) . length) . (nub <$>) . transpose . (inits <$>)▼
in case lng of
0 -> []
_ ->
head $
(take 1 .
xs
abbreviations :: String -> [String]
abbreviations = (fmap (unwords
main :: IO ()
main = do
s <- readFile "./weekDayNames.txt"
mapM_ putStrLn $ take 5 (abbreviations s)
</lang>
{{Out}}
<pre>Su Mo Tu We Th Fr Sa
|