8 POINTS |
Problem 1. Here are some problems concerning simple functions:
Write down the contract, purpose statement and header for a function that computes the distance that a rocket has traveled, given the time since its launch.
Solution:
;; distance : Number Number -> Number [PT: 1] ;; the distance that a rocket has traveled, ;; given the time since launch [PT 1] (define (distance t) ...) ;; [PT 1]
Provide three examples for a function that computes how far a car has traveled in t seconds according to the formula
distance(t) = - 1/2 · 10 · t2 + 100 |
Solution:
[PT 3] t seconds | distance ---------------------- 0 | 100 1 | 95 2 | 80