Binary to decimal conversion

0

I did an algorithm that converts from Binary to Decimal, now I need to develop one that does the opposite. I'll leave the code I made below, but this one is in error. Thank you.

converte' :: [Int] -> Int
converte' [] = 0
converte' (x:xs) = ((2 ^ comprimento xs) * x) + (2 ^ (comprimento xs-1)) * x

ps: function comprimento measures the size of the current list's tail

    
asked by anonymous 07.11.2018 / 17:29

0 answers