(define print-poly ;TYPE: (-> (poly) void)
  (lambda (poly)
    ; EFFECT: print external form of poly
    ; e.g., 3 x^{42} + -8 x^2 + 2 x + 4.1
    (letrec
      ((display-leading-term
        ; TYPE: (-> (poly) void)
        (lambda (p)
          ; EFFECT: print the leading term of p
          (begin
            (display (leading-coef p))
            (display " ")
            (display-degree (degree p)))))

       (display-degree ; TYPE: (-> (integer) void)
        (lambda (n)
          ; REQUIRES: n >= 0
          ; EFFECT: print x and degree in the
          ; standard format for polynomials
          (cond
           ((= n 1) (display "x"))
           ((= n 0) (display ""))
           ((and (> n 1) (< n 10))
            (begin
              (display "x^")
              (display n)))
           (else (begin
                   (display "x^{")
                   (display n)
                   (display "}"))))))
       (print-helper  ; TYPE: (-> (poly) void)
        (lambda (p)
          ; EFFECT: Print + and then poly, 
          ; not printing 0 terms
          (if (zero-poly? p)
              (newline)
              (begin
                (display " + ")
                (display-leading-term p)
                (print-helper (rest-of-poly p))))
          ))
       )
      (begin
        (display-leading-term poly)
        (print-helper
         (rest-of-poly poly))))))

