The Design Recipe:
Used to leave a written explanation for the function.
Contract: Describes what type of arguments the function consumes and what type of value it produces. Contract should
also contain constants used in the code. (Num, Int, Nat, Any)
Purpose: Describes what the function is to compute.
Examples: Illustrating the use of the function.
Deﬁnition: The Scheme deﬁnition (header and body) of the function.
Tests: A representative set of inputs and expected outputs. Tests can handle complexities in the body. Tests should be
small and directed and always worked out by hand.
Useful functions for testing:
(check-expect (sum-of-squares 3 4) 25)
(check-within (sqrt 2) 1.414 .001)
(check-error (/ 1 0) "/: division by zero")
Functions which produce only a “true” or “false” value. Examples:
(= x y), (< x y), (> x y), (<= x y), (>= x y)
A sample contract:
;; = : Num Num Boolean
Booleans can be combined using “and” and “or” functions. Example:
(and (> 5 4) (< 6 8))
A predicate is a function which produces a Boolean result. Scheme h