How to Design Programs: An Introduction to Programming and Computing

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

View Full Document Right Arrow Icon
WPI CS536 (F07) Homework 6 CS 536 Homework 6: Continuations Due: October 25, both hardcopy in class and electronically via turnin (asgmt name hwk6 ) Problem 1 Any program that consumes some amount of stack, when converted to CPS and run, suddenly consumes no stack space at all. Why? Does this make CPS a good general technique for reducing the space consumption of programs? Problem 2 CPS the following Scheme function. You don t need to CPS primitives such as empty? , first , rest , cons , cons? and < . Assume that the function argument to filter is in CPS. Feel free to do this manually (as we did for web programs), rather than using the lambda-heavy transformation covered in chapter 18 (the convert method covered at the end of class). ;; filter: (x -> bool) (listof x) -> (listof x) (define (filter f l) (cond [(empty? l) empty] [else (cond [(f (first l)) (cons (first l) (filter f (rest l)))] [else (filter f (rest l))])])) Now change the following expressions to use the CPSed version of filter .
Image of page 1

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

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