Longest common suffix: Difference between revisions

→‎{{header|Haskell}}: added an initial draft in Haskell, pending improvement of the task specification
(Added Go)
(→‎{{header|Haskell}}: added an initial draft in Haskell, pending improvement of the task specification)
Line 213:
[] -> ""
</pre>
 
=={{header|Haskell}}==
This task clearly needs a little more work to bring it up to the usual standard – its' rather underspecified and bereft of test samples – but one response, for the moment, might be something like:
<lang haskell>import Data.List (transpose)
 
longestCommonSuffix :: [String] -> String
longestCommonSuffix =
reverse .
head . transpose . takeWhile (all =<< (==) . head) . transpose . fmap reverse
 
main :: IO ()
main =
mapM_
(putStrLn . longestCommonSuffix)
[ [ "Sunday"
, "Monday"
, "Tuesday"
, "Wednesday"
, "Thursday"
, "Friday"
, "Saturday"
]
, [ "Sondag"
, "Maandag"
, "Dinsdag"
, "Woensdag"
, "Donderdag"
, "Vrydag"
, "Saterdag"
, "dag"
]
]</lang>
{{Out}}
<pre>day
dag</pre>
 
 
=={{header|Julia}}==
9,655

edits