I am not an expert at Haskell, but this is the easiest way I can come up with to solve this problem, which does not involve the use of any other external functions.
concatDigits :: [Int] -> Int concatDigits [] = 0 concatDigits xs = concatReversed (reverseDigits xs) 1 reverseDigits :: [Int] -> [Int] reverseDigits [] = [] reverseDigits (x:xs) = (reverseDigits xs) ++ [x] concatReversed :: [Int] -> Int -> Int concatReversed [] d = 0 concatReversed (x:xs) d = (x*d) + concatReversed xs (d*10)
As you can see, I assumed that you are trying to make a list of numbers. If for some reason this is not your case, I am sure it will not work. :(
In my solution, first of all, I defined a function called reverseDigits that reverses the original list. For example, [1,2,3] - [3,2,1]
After that, I use the concatReversed function concatReversed which takes a list of digits and the number d, which is the result of a tenfold increase in the first digit at the position of the list. If the list is empty, it returns 0, and if not, it returns the first digit in the list times d, plus a call to concatReversed passing the rest of the list, and d times 10.
Hope the code speaks for itself, because I think my poor English explanation didn't help much.
edit
After a long time, I see that my decision is very dirty, as it requires turning the list so that you can multiply each digit by 10 and increase the index of the digit in the list from right to left. Now, knowing the tuples, I see that a much better approach is to have a function that receives both the accumulated converted part and the rest of the list, so with each call, the function multiplies the accumulated part by 10, and then adds the current digit.
concatDigits :: [Int] -> Int concatDigits xs = aggregate (xs, 0) where aggregate :: ([Int], Int) -> Int aggregate ([], acc) = acc aggregate (x:xs, acc) = aggregate (xs, (acc * 10 + x))