Question: we used denotational semantics to evaluate a decimal number using a function Mdec. We could define a similar function to evaluate hexadecimal numbers as follows:
we used denotational semantics to evaluate a decimal number using a function Mdec. We could define a similar function to evaluate hexadecimal numbers as follows: MhexDigit(0) = 0,, MhexDigit(9) = 9, MhexDigit(A) = MhexDigit(a) = 10,,MhexDigit(B) = MhexDigit(b) = 11,, MhexDigit(F) = MhexDigit(f) = 15 Mhex(d) = MhexDigit(d) (Base case one-digit string) Mhex(dndn-1d1d0) = Mhex(dndn-1d1)*16 + MhexDigit(d0) Note that I am allowing both upper- and lower-case letters for the hexadecimal digits for 10,11,,15. Implement a Haskell function mHexDigit to return the numerical value of a single hexadecimal digit. You will need to use guards and the ord function from the Haskell module Data.Char. The Haskell type should be mHexDigit::Char -> Int Now, implement a Haskell function mHex::String -> Int to evaluate a hexadecimal number given as a string. Finally, since mHexDigit is only used by mHex, implement a Haskell function mHex::String -> Int in which mHexDigit is defined using the where or let contruct.

2. n class, we used denotational semantics to evaluate a decimal number using a function Mdec. We could define a similar function to evaluate hexadecimal numbers as follows: MhexDigit ( 'F' ) = MhexDigit ( 'f' ) -15 Mhex ("d") MhexDigit (d' (Base case one-digit string) Note that I am allowing both upper- and lower-case letters for the hexadecimal digits for 10,11. ,15. Implement a Haskell function mHexDigit to return the numerical value of a single hexadecimal digit. You will need to use guards and the ord function from the Haskell module Data.Char. The Haskell type should be mHexDigit::Char -> Int Now, implement a Haskell function mHex:String -Int to evaluate a hexadecimal number given as a string Finally, since mHexDigit is only used by mHex, implement a Haskell function mHex': String-> Int in which mHexDigit is defined using the where or let contruct. 2. n class, we used denotational semantics to evaluate a decimal number using a function Mdec. We could define a similar function to evaluate hexadecimal numbers as follows: MhexDigit ( 'F' ) = MhexDigit ( 'f' ) -15 Mhex ("d") MhexDigit (d' (Base case one-digit string) Note that I am allowing both upper- and lower-case letters for the hexadecimal digits for 10,11. ,15. Implement a Haskell function mHexDigit to return the numerical value of a single hexadecimal digit. You will need to use guards and the ord function from the Haskell module Data.Char. The Haskell type should be mHexDigit::Char -> Int Now, implement a Haskell function mHex:String -Int to evaluate a hexadecimal number given as a string Finally, since mHexDigit is only used by mHex, implement a Haskell function mHex': String-> Int in which mHexDigit is defined using the where or let contruct
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
