;;;; This example illustrates the use of the design recipe for ;;;; functions consuming simple (atomic) data. ;; (Step 2) Contract/purpose/header ;; gas-cost : Number Symbol -> Number ;; computes total cost based on no. of gallons and grade ;; (define (gas-cost gallons octane) ...) ;; (Steps 4 and 5) Template, then body (define (gas-cost gallons grade) (cond [(symbol=? grade 'regular) (* gallons 1.45)] [(symbol=? grade 'plus) (* gallons 1.55)] [(symbol=? grade 'premium) (* gallons 1.65)] )) ;; (Step 3) Examples and (Step 6) Tests (gas-cost 1 'regular) "should be" 1.45 (gas-cost 5 'plus) "should be" 7.75 (gas-cost 10 'premium) "should be" 16.50