I have a problem that I can't solve, I have a function called 'shorten'
shorten :: [(Char,Int)] -> String shorten as = concat(map shorten' as) shorten' :: (Char,Int) -> String shorten' (x,n) = [x,intToDigit n]
which produces the output
> shorten [('a'; 5); ('b'; 4); ('c'; 2)]
"a5b4c2"
but I need to make a function is essentially the inverse function of shorten called expand.
expand :: String -> [(Char; Int)]
that produces the following output
> expand "a5b4c2"
[('a'; 5); ('b'; 4); ('c'; 2)]
> expand "d9d3"
[('d'; 9); ('d'; 3)]
and I can't figure it out. I would appreciate any help as this is my last question.
with regards, Neoya


Sign In
Create Account

Back to top









