This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: CS 135 Winter 2011 Brad Lushman Assignment: 4 Due: Wednesday, February 9, 2011, 9:30am Language level: Beginning Student Allowed recursion: Structural Files to submit: list.rkt , lde.rkt , poly.rkt Warmup exercises: HtDP 8.7.2, 9.1.1 (but use boxandpointer diagrams), 9.1.2, 9.5.3, 10.1.4, 10.1.5, 11.2.1, 11.2.2, 11.4.3, 11.5.1, 11.5.2, 11.5.3 Practise exercises: HtDP 8.7.3, 9.5.4, 9.5.6, 9.5.7, 10.1.6, 10.1.8, 10.2.4, 10.2.6, 10.2.9, 11.4.5, 11.4.7 Here are the assignment questions you need to submit. 1. Perform the Assignment 4 questions using the online evaluation “Stepping Problems” tool linked to the course web page and available at https://www.student.cs.uwaterloo.ca/ ˜ cs135/stepping The instructions are the same as A03; check there for more information, if necessary. Re minder: You should not use DrRacket’s Stepper to help you with this question, for a few reasons. First, as mentioned in class, DrRacket’s evaluation rules are slightly different from the ones presented in class; you are to use the ones presentedin class. Second, in an exam sit uation, of course, you will not have the Stepper to help you. Third, you can reenter steps as many times as necessary to get them correct, so you might as well maximize the educational benefit. 2. In the file list.rkt : (a) Use the template for functions that consume a ( listof int ) to write countpositives , which consumes a ( listof int ) and produces a count of all the positive numbers in the list. (b) Use the template to write the predicate somenegative? , which consumes a ( listof int ) and produces true if and only if at least one number in the list is negative. (c) Use the template to write the predicate alternating? , which consumes a ( listof int ) and produces true if and only if the list alternates between even and odd numbers. For example ( cons 1 ( cons 4 ( cons 5 empty ))) and ( cons 2 ( cons 3 ( cons 2 empty ))) are alternating. The empty list is considered to be alternating. A ( listof int ) of length 1, consisting of a single integer, is also considered to be alternating....
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.
 Winter '07
 VASIGA
 Recursion

Click to edit the document details