Write the function weight
.
Solution
;; weight : fern->
number (define (weight a-fern) (cond [(leaf? a-fern) (* 0.5 (leaf-area a-fern))] [(branch? a-fern) (+ (* pi (branch-thickness a-fern) (branch-thickness a-fern) (branch-length a-fern)) (weight-lof (branch-left a-fern)) (weight-lof (branch-right a-fern)))])) ;; weight-lof : list-of-fern->
number (define (weight-lof a-lof) (cond [(empty? a-lof) 0] [(cons? a-lof) (+ (weight (first a-lof)) (weight-lof (rest a-lof)))]))