-
-
Save coodoo/372c34e936740104aaa3d2456d264158 to your computer and use it in GitHub Desktop.
Find first not repeated char in a string. "Technical question" -> h. "Backend" -> b
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- f (x:xs) = case x `elem` xs of | |
-- True -> f xs | |
-- False -> x | |
f s = f' $ map toLower s | |
where | |
f' (x:xs) = | |
case x `elem` xs of | |
True -> f' xs | |
False -> x | |
f s = f' $ map toLower s | |
where f' (x:xs) = case x `elem` xs of True -> f' xs; False -> x | |
-- one liner version using if/else/then | |
f s = f' $ map toLower s where f' (x:xs) = if x `elem` xs then f' xs else x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment