Longest palindromic substrings: Difference between revisions
Content added Content deleted
m (→{{header|Haskell}}: Tidied some if then else away) |
|||
Line 94: | Line 94: | ||
<lang haskell>-------------- LONGEST PALINDROMIC SUBSTRINGS ------------ |
<lang haskell>-------------- LONGEST PALINDROMIC SUBSTRINGS ------------ |
||
longestPalindromes :: String -> ([String], Int) |
longestPalindromes :: String -> ([String], Int) |
||
longestPalindromes s = go $ palindromes s |
longestPalindromes s = go $ palindromes s |
||
Line 112: | Line 111: | ||
palindromicNuclei :: String -> [(String, (String, String))] |
palindromicNuclei :: String -> [(String, (String, String))] |
||
palindromicNuclei |
palindromicNuclei = |
||
concatMap go . |
|||
⚫ | |||
where |
where |
||
contexts = (init . tail) (zip prefixes suffixes) |
|||
⚫ | |||
suffixes = scanr (:) [] s |
|||
go (a@(x:_), b@(h:y:ys)) = |
go (a@(x:_), b@(h:y:ys)) = |
||
if x == h |
if x == h |