Jump to content

Determine if a string is collapsible: Difference between revisions

m
Line 649:
import Text.Printf (printf)
import Data.Maybe (catMaybes)
import Control.Monad (guard)
 
input :: [String]
Line 662 ⟶ 663:
 
collapse :: Eq a => [a] -> [a]
collapse s = catMaybes $ zipWith (\a b -> ifguard (a /= b) then>> a else Nothing) (Nothing : ms) (ms <> [Nothing])
where ms = map Just s
 
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.