;; The first three lines of this file were inserted by DrScheme. They record metadata ;; about the language level of this file in a form that our tools can easily process. #reader(lib "htdp-beginner-reader.ss" "lang")((modname lect02a) (read-case-sensitive #t) (teachpacks ((lib "universe.ss" "teachpack" "2htdp"))) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ((lib "universe.ss" "teachpack" "2htdp"))))) ; blend3 : string, string, string -> string ; return w1,w2 blended, then a space, then w2,w3 blended. ; (See lect01c-examples.ss, for def'n of 'blend'.) ; (define (blend3 w1 w2 w3) ;; N.B. Requires `blend` from lect01c-examples.ss. (string-append (blend w1 w2) " " (blend w2 w3))) ; To write: `blend3`: (check-expect (blend3 "Ian" "Thomas" "Barland") "Imas Tholand") (check-expect (blend3 "a" "b" "c") "b c") (check-expect (blend3 "hey" "there" "") "here th") (check-expect (blend3 "hey" "" "there") "h ere") (check-expect (blend3 "hey" "there" "everybody") "here thybody") ; N.B. This last test-case is unnecessary: it doesn't ; really test anything that the first example didn't. ; area-of-disc : real -> real ; (define (area-of-disc r) (* pi r r)) ; area-of-ring : real, real -> real ; COmpute the surface area of an annulus whose ; outer radius is `outer` and inner radius is `inner`; ; must have (<= 0 inner outer). ; (define (area-of-ring outer inner) (- (area-of-disc outer) (area-of-disc inner))) (check-expect (area-of-disc 0) 0) (check-within (area-of-disc 1) pi 0.0000001) (check-within (area-of-disc 10) 314.1592653589793238462643383279 0.000001) (check-within (area-of-ring 0 0) 0 0) (check-within (area-of-ring 1 0) pi 0.0001) (check-within (area-of-ring 17 17) 0 0.0001) (check-within (area-of-ring 10 5) (- 314.159265 (area-of-disc 5)) 0.0001)