cs61a_sp08_mt1-05

cs61a_sp08_mt1-05 - exercise 1.43 page 77 But in fact this...

Info icon This preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Question 7 (7 points): This question is about the iterative-improve procedure from exercise 1.46, page 78: (define (iterative-improve good-enough? Improve) (define (help x) (if (good-enough? x) x (help (improve x)))) help) (a) Fill in the blanks in the following definition of piglatin: (define (piglatin wd) (word ((iterative-improve ______________________________________________________________________ _______________________________________________________________________ ) wd) ay)) (b) Another candidate for rewriting in terms of iterative-improve would be the repeated function from
Image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: exercise 1.43, page 77. But in fact this doesn’t work, because the “good enough” condition depends not on the current argument value, but on the number of times the function has been called. Write a function count-iterative-improve that’s like iterative-improve except that each of its two argument functions takes two arguments: the current guess, and the number of times the improve function has been called so far. Here’s how it will be used: (define (repeated fn num) (count-iterative-improve (lambda (x cnt) (= cnt num)) (lambda x cnt) (fn x))))...
View Full 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