Problem 6.   Dr. Cha Len, now residing in CH (short for Switzerland), has uncovered these structure and data definitions:

(define-struct more (extras one))
;; A More is one of:
;; -- Number
;; -- (make-more More Number)

He is a natural explorer and is now trying to design the function most, which consumes a More and produces the largest number in it.

Hint: max is picks the larger of two numbers: (max 3 10) is 10.



Solution:

;; Grader: Prof. Proulx

;; data examples: [1pt]
;; -- 3
;; -- (make-more 3 10)
;; -- (make-more (make-more 3 10) 11)

;; most : More -> Number [1pt]
;; the largest number in m 
(define (most m)
  (cond ;; [1pts: for 2 cond lines]
    [(number? m) m] 
    ;; [1 pt for selectors,
    ;;  1 for recursion]
    [else (max (most (more-extras m)) (more-one m))]))

;; Examples/tests: [1 for functional example/test]
(equal? (most (make-more 10 3)) 10)