2
Code Haskell:
bin2dec::[Integer]->Integer
bin2dec (h:[]) = h
bin2dec (h:t) = h*(2^length(t))+bin2dec(t)
bin2frac :: ([Integer], [Integer]) -> Double
bin2frac(x,y) = fromDouble(bin2dec(x)) * 10 ^ bin2dec(y)
Goal:
Define a recursive function that takes a tuple with two binary values representing, respectively, the mantissa and the exponent of a number and returns the corresponding decimal fraction.
What is your doubt?
– ptkato
@Patrick I think it’s the mistake in the title:
Couldn't match expected type
Double' with actual typeInteger'
, that must be it.– user3603