a02-cs135-w10 - CS 135 Winter 2011 Brad Lushman Assignment:...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CS 135 Winter 2011 Brad Lushman Assignment: 2 Due: Wednesday, January 19, 9:30am Language level: Beginning Student Files to submit: cond.rkt , grades.rkt , risk.rkt , intervals.rkt Warmup exercises: HtDP 4.1.1, 4.1.2, 4.3.1, 4.3.2 Practise exercises: HtDP 4.4.1, 4.4.3, 5.1.4 Policies from Assignment 1 carry forward. For example, your solutions must be entirely your own work, and your solutions will be marked for both correctness and good style. Good style includes qualities such as descriptive names, clear and consistent indentation, appropriate use of helper functions, and documentation (design recipe). For this and all subsequent assignments you are expected to use the design recipe as discussed in class. You must use check-expect for both examples and tests. It is very important that the function names and parameters match ours. You must use the public tests to be sure. The names of the functions will be given exactly. The names of the parameters are up to you, but should be meaningful. The order and meaning of the parameters are carefully specified in each problem. Here are the assignment questions you need to submit. 1. A cond expression can always be rewritten to produce equivalent expressions . These are new expressions that always produce the same answer as the original (given the same inputs, of course). For example, the following are all equivalent: ( cond [( > x ) One ] [( < = x ) Two ]) ( cond [( < = x ) Two ] [( > x ) One ]) ( cond [( > x ) One ] [ else Two ]) (There is one more really obvious equivalent expression; think about what it might be.) So far all of the cond examples weve seen in class have followed the pattern ( cond [ question1 answer1 ] [ question2 answer2 ] ... [ questionk answerk ]) where questionk might be else . The questions and answers do not need to be simple expressions like weve seen in class. In particular, either the question or the answer (or both!) can themselves be cond expressions. In this problem, you will practice manipulating these so-called nested cond expressions. CS 135 Winter 2011 Assignment 2 1 Below are three functions whose bodies are nested cond expressions. You must write new versions of these functions, each of which uses exactly one cond . Your versions must be equivalent to the originalsthey should always produce the same answers as the originals, regardless of x or the definitions of the helper predicates....
View Full Document

This note was uploaded on 10/02/2011 for the course CS 135 taught by Professor Vasiga during the Winter '07 term at Waterloo.

Page1 / 6

a02-cs135-w10 - CS 135 Winter 2011 Brad Lushman Assignment:...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online