Longest palindromic substrings: Difference between revisions

m
→‎{{header|Haskell}}: Tidied some if then else away
(→‎{{header|Haskell}}: Slightly expanded range of examples)
m (→‎{{header|Haskell}}: Tidied some if then else away)
Line 96:
 
longestPalindromes :: String -> ([String], Int)
longestPalindromes s = (filtergo ((w$ ==)palindromes . length) cs, w)s
where
go xs = palindromes s
| null xs = (return <$> s, 1)
cs =
| otherwise = (filter ((w ==) . length) xs, w)
if null xs
then return <$> swhere
elsew = maximum $ length <$> xs
w =
if null xs
then 1
else maximum $ length <$> xs
 
palindromes :: String -> [String]
Line 127 ⟶ 123:
| x == y ]
go _ = []
 
 
--------------------------- TEST -------------------------
9,655

edits