Determine if a string is collapsible: Difference between revisions
Content deleted Content added
m →{{header|Haskell}}: improved |
|||
Line 662: | Line 662: | ||
collapse :: String -> String |
collapse :: String -> String |
||
collapse s = catMaybes $ zipWith(\a b -> if a /= b then a else Nothing) (Nothing : ms) ( |
collapse s = catMaybes $ zipWith(\a b -> if a /= b then a else Nothing) (Nothing : ms) (ms <> [Nothing]) |
||
where ms = map Just s |
where ms = map Just s |
||