Skip to content

Instantly share code, notes, and snippets.

@ujihisa

ujihisa/doya.hs

Created Aug 15, 2011
Embed
What would you like to do?
main = do
print $ hoge ["abcdef", "abc123"]
print $ hoge ["あいうえお", "あいうえさん", "あいどる"]
print $ hoge ["12345", "67890", "12abc"]
heads :: [String] -> [Maybe Char]
heads xs = map f xs
where
f [] = Nothing
f (x:_) = Just x
same :: Eq a => [a] -> Bool
same [] = True
same (x:xs) = all (== x) xs
hoge :: [String] -> [String]
hoge xs
| same (heads xs) = hoge $ map tail xs
| otherwise = xs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment