Longest palindromic substrings: Difference between revisions
Content deleted Content added
→{{header|Haskell}}: Slightly expanded range of examples |
m →{{header|Haskell}}: Tidied some if then else away |
||
Line 96: | Line 96: | ||
longestPalindromes :: String -> ([String], Int) |
longestPalindromes :: String -> ([String], Int) |
||
longestPalindromes s = |
longestPalindromes s = go $ palindromes s |
||
where |
where |
||
xs |
go xs |
||
| null xs = (return <$> s, 1) |
|||
cs = |
|||
| otherwise = (filter ((w ==) . length) xs, w) |
|||
if null xs |
|||
where |
|||
w = maximum $ length <$> xs |
|||
w = |
|||
if null xs |
|||
then 1 |
|||
else maximum $ length <$> xs |
|||
palindromes :: String -> [String] |
palindromes :: String -> [String] |
||
Line 127: | Line 123: | ||
| x == y ] |
| x == y ] |
||
go _ = [] |
go _ = [] |
||
--------------------------- TEST ------------------------- |
--------------------------- TEST ------------------------- |