a08-cs135-w10

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

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

CS 135 Winter 2011 Brad Lushman Assignment: 8 Due: Wed., March 23, 2011, 9:30am Language level: Intermediate Student with Lambda Allowed recursion: None. Files to submit: alfs.rkt , add-funcs.rkt Warmup exercises: HtDP 19.1.5, 20.1.1, 20.1.2, 24.0.7, 24.0.8, Without using explici t recursion: 9.5.2, 9.5.4 Practise exercises: HtDP 19.1.6, 20.1.3, 21.2.3, 24.0.9, 20.2.4, 24.3.1, 24.3.2 For this assignment: you may use the abstract list functions in Table 57 of the textbook ( http://www.htdp. org/2003-09-26/Book/curriculum-Z-H-27.html#node_sec_21.2 ). you may use primitive functions such as mathematical functions, cons , ﬁrst , rest , list , emp ty? , local , etc. you may not use length , append , reverse and similar “non-primitive” functions unless ex- plicitly allowed. you may not use explicit recursion (functions that call themselves, either directly or indi- rectly) except in the construction of requested abstract list functions. Nesting abstract list functions can become confusing. Use appropriately documen ted helper func- tions liberally to help clarify your intentions. Here are the assignment questions you need to submit. 1. The stepping problems for Assignment 8 at https://www.student.cs.uwaterloo. ca/ ˜ cs135/stepping/ 2. Construct the following functions using abstract list functions. Do not use explicit recursion (no credit will be given for explicitly recursive solutions): (a) The function x-coords , which consumes a list of posn s, and produces the list of all of the x-coordinates of the posn s in the given list. (b) The function x-coords-of-posns , which consumes a list of anything at all, and produces the list of all of the x-coordinates of the posn s in the list. (c) The function alternating-sum , which consumes a list of numbers ( list a1 a2 . . . an ) and produces the alternating sum a 1 - a 2 + a 3 - a 4 + ··· ( - 1) n - 1 an . CS 135 — Winter 2011 Assignment 8 1

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

View Full Document
(d) The function ﬁrst-col which consumes a ( listof ( listof num )), denoting a rectangular matrix of numbers, and produces the ﬁrst column of the matrix, as a list. For example, ( ﬁrst-col ’(( 1 2 3 4 ) ( 5 6 7 8 ) ( 9 10 11 12 ))) yields ( list 1 5 9 ) (e) The function add1-mat which consumes a ( listof ( listof num )), denoting a rectangular matrix of numbers, and produces the matrix resulting from adding 1 to every entry of the matrix. For example, ( add1-mat ’(( 1 2 3 4 ) ( 5 6 7 8 ) ( 9 10 11 12 ))) yields ( list ( list 2 3 4 5 ) ( list 6 7 8 9 ) ( list 10 11 12 13 )) (f) The function
This is the end of the preview. Sign up to access the rest of the 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 / 5

a08-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
Ask a homework question - tutors are online