India's Horizon phone company, founded in 2010, stores phone numbers in their local area switches according to the following structure and data definitions:
  (define-struct phone (area switch num))
  ;; A PhoneNumber is a structure: 
  ;;   (make-phone AC SC SWON)

  ;; An AC is a natural number between 200 and 999

  ;; A SC is a natural number between 200 and 999

  (define-struct swon (d1 d2 d3 d4))
  ;; A SWON is a structure: 
  ;;   (make-swon Digit Digit Digit Digit)

  ;; A Digit is one of: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

Their programs deal with recording the phone calls, directing them, monitoring hardware failures, etc. To increase their profit, however, they have off-shored the creation of phone bills to your CheapHacks company, located in cheap-labor Bos-tone. Your boss has asked you to do the following over the weekend:

  1. Translate the CCIS office phone number, which is (617) 373-2461, into Horizon's data representation.



    Solution:

    Grader: Theo

      ;; [PTS: 1]
      (make-phone 617 373 (make-swon 2 4 6 1))
    

  2. Design the function report, which consumes a phone number and produces a string, according to standard convention. For example, the representation of the CCIS office phone number would produce "(617) 373-2461". Hint: number->string converts a number (digit) into a string; string-append juxtaposes strings.



    Solution:

      ;; report : PhoneNumber -> String [PTS 1]
      ;; convert the given phone number into a string [PTS 1]
      (define (report pn) 
        ;; [PTS 2: 1 for the selectors, 1 for correctness]
        (string-append 
         "(" (number->string (phone-area pn)) ")"
         " "
         (number->string (phone-switch pn))
         "-"
         (swon-report (phone-num pn))))
    
      ;; [PTS +3 if correctly in-lined]
      ;; swon-report : SWON -> String [PTS 1]
      ;; convert the given swon to a string [PTS 1]
      (define (swon-report s)
        ;; [PTS 2: selectors, correctness]
        (string-append (number->string (swon-d1 s))
                       (number->string (swon-d2 s))
                       (number->string (swon-d3 s))
                       (number->string (swon-d4 s))))
    
      ;; TESTS: [PTS 2, 1 per function]
      (equal? (swon-report (make-swon 2 4 6 1))
              "2461")
      (equal? (report 
                (make-phone 617 373 (make-swon 2 4 6 1)))
              "(617) 373-2461")
    

  3. If Horizon decides to change the structure definition for phone to

      (define-struct phone (area switch local))
    

    at how many places and how do you have to change your solution?



    Solution:

      [PTS 1 for full answer]
      once, I must replace phone-num with phone-local 
      XOR [if they in-lined]
      four, I must replace all phone-num/s with phone-local/s