Chapter 3 Daily 02

Note: in the list of digits, we will make the smallest place value come first. In [9,0,5], the ones digit is 9.

  1. (hd) Write a helper function take in a single integer between 0 and 15 (inclusive) and return a string containing the corresponding hexadecimal digit. The digits are 10=“A”, 11=“B”, etc.

     "B" == hd 11
    
  2. (hexShow) Take in a list of values of hexadecimal digits (so integers, like [10,11]. Output a string with the hex number “AB”.

     "F00D" == hexShow [13,0,0,15]
    
  3. (hexDec) Input a list of values of hexadecimal digits, like [13,0,0,15] and output the value of the actual number.

     61453 == hexDec [13,0,0,15]
    

    Each number represents the decimal value of a base 16 digit:

     15*16^3 + 0*16^2 + 0*16^1 + 13*16^0
    
  4. If you discussed this in class, write hexParse :: String -> [Int] to produce a the list of values of hexadecimal digits.

     [13,0,0,15] == hexParse "F00D"