Skip to content

Instantly share code, notes, and snippets.

@ujihisa
Created August 15, 2011 04:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ujihisa/1145718 to your computer and use it in GitHub Desktop.
Save ujihisa/1145718 to your computer and use it in GitHub Desktop.
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