I would go and make a helper function f :: Integer -> String and one g :: String -> Integer , where f 1 = "a" , ... f 27 = "aa" , f 28 = "ab" and t .d. and inverse g .
Then incrementString = f . succ . g incrementString = f . succ . g
Note. I skipped f implementation for training
Update
for another approach, you can define an increment with the transport function inc' :: Char -> (Char, Bool) , and then
incString :: String -> String incString = reverse . incString' where incString' [] = [] incString' (x:xs) = case inc' x of (x',True) -> x': incString' xs (x',False) -> x':xs
Note: this function is not tail recursive!
source share