Longest palindromic substrings: Difference between revisions

m
m (→‎{{header|Haskell}}: Tidied some if then else away)
Line 94:
 
<lang haskell>-------------- LONGEST PALINDROMIC SUBSTRINGS ------------
 
longestPalindromes :: String -> ([String], Int)
longestPalindromes s = go $ palindromes s
Line 112 ⟶ 111:
 
palindromicNuclei :: String -> [(String, (String, String))]
palindromicNuclei s = contexts >>= go
concatMap go .
init . prefixestail =. ((zip . scanl (flip ((<>) . return)) []) s<*> scanr (:) [])
where
contexts = (init . tail) (zip prefixes suffixes)
prefixes = scanl (flip ((<>) . return)) [] s
suffixes = scanr (:) [] s
go (a@(x:_), b@(h:y:ys)) =
if x == h
9,655

edits