; A list-of-num is either ; - empty ; - (make-bigger-list num list-of-num) (define-struct bigger-list (first rest)) ; aq-weight : list-of-num -> num (define (aq-weight l) (cond [(empty? l) 0] [(bigger-list? l) (+ (bigger-list-first l) (aq-weight (bigger-list-rest l)))])) (aq-weight empty) "should be" 0 (aq-weight (make-bigger-list 3 empty)) "should be" 3 ;; ======================================== ;; Using the short names: cons, etc. ;; ======================================== ; A list-of-num is either ; - empty ; - (cons num list-of-num) ; Aq-weight : list-of-num -> num (define (Aq-weight l) (cond [(empty? l) 0] [(cons? l) (+ (first l) (Aq-weight (rest l)))])) (Aq-weight empty) "should be" 0 (Aq-weight (cons 1 (cons 2 empty))) "should be" 3