Textbook Notes (368,629)
Canada (162,027)
CS 135 (5)
Chapter

# Module 2 - The Design Recipe.docx

2 Pages
152 Views

School
Department
Computer Science
Course
CS 135
Professor
Sandy Graham
Semester
Fall

Description
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") Boolean-valued functions: 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)) => true Predicates: A predicate is a function which produces a Boolean result. Scheme h
More Less

Related notes for CS 135
Me

Log In

OR

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Sign up

Join to view

OR

By registering, I agree to the Terms and Privacy Policies
Already have an account?
Just a few more details

So we can recommend you notes for your school.

Reset Password

Please enter below the email address you registered with and we will send you a link to reset your password.

Add your courses

Get notes from the top students in your class.

Request Course
Submit