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

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

View Full Document Right Arrow Icon
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 , first , 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
Image of page 1

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

View Full Document Right Arrow Icon
(d) The function first-col which consumes a ( listof ( listof num )), denoting a rectangular matrix of numbers, and produces the first column of the matrix, as a list. For example, ( first-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 sum-at-zero , which consumes a list of functions ( f 1 , . . . , f n ) (which con- sume and produce a number), and produces the value f 1
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern