Exercise 3.3.4: (back)
;; constant (define PI 3.142) ;; square : number -> number (define (square x) (* x x)) ;; area-circle : number -> number (define (area-circle radius) (* PI (square radius))) ;; circumference-circle : number -> number (define (circumference-circle radius) (* 2 PI radius)) ;; area-cylinder-side : number number -> number (define (area-cylinder-side radius length) (* (circumference-circle radius) length)) ;; area-pipe : number number number -> number ;; A pipe has an inside surface and a outside surface ;; and a top and bottom surface. (define (area-pipe radius length thickness) (+ (+ (area-cylinder-side radius length) (area-cylinder-side (+ radius thickness) length)) (* 2 (- (area-circle (+ radius thickness)) (area-circle radius)))))
;; area-pipe : number number number -> number ;; A pipe has an inside surface and a outside surface ;; and a top and bottom surface. (define (area-pipe radius length thickness) (+ (+ (* (* 2 3.142 radius) length) (* (* 2 3.142 (+ radius thickness) length))) (* 2 (- (* 3.142 (* (+ radius thickness) (+ radius thickness))) (* 3.142 (* radius radius))))))