Homework 6: Continuations

How to Design Programs: An Introduction to Programming and Computing

Info iconThis 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
Background image of page 1

Info iconThis 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 ]}

Page1 / 2

Homework 6: Continuations - WPI CS536(F07 Homework 6 CS 536...

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

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