Split a character string based on change of character: Difference between revisions
Content added Content deleted
(→{{header|Haskell}}: Added a variant expressed in terms of `span`) |
|||
Line 1,252: | Line 1,252: | ||
charGroups :: String -> [String] |
charGroups :: String -> [String] |
||
charGroups [] = [] |
charGroups [] = [] |
||
charGroups (c : cs) = |
charGroups (c : cs) = |
||
let (xs, ys) = span (c ==) cs |
|||
where |
|||
(xs |
in (c : xs) : charGroups ys |
||
main :: IO () |
main :: IO () |