views:

31

answers:

1

Hi all

I'm looking at Scheme at the moment for a bit of fun, using the "how do design programs" book. All pretty easy so far but ran into this odd wording in exercise 6.6.1 where I'm not clear what is intended:

Develop the template fun-for-circle, which outlines a function that consumes circles. Its result is undetermined.

One possibility seems to be that is is asking me to define a higher order function, but that just doesn't seem to fit as lambda expressions haven't been covered by the book yet and that would be rather jumping before you can walk if you were following the book through as a novice developer.

The other option seems to be simply to write as a comment the rough manner in which a function would look. However, that doesn't appear to fit with the following instructions in exercise 6.6.2 to use it:

Use fun-for-circle to develop draw-a-circle.

I'm sure I'm missing something obvious here, but I'm not sure what. Unfortunately I cannot check the answers to see what it intends as I do not have the password. Anybody got any insight?

+2  A: 

In HtDP, a template is a kind of a sketch of a function, which basically lists everything that you know about the inputs, including fields and often the result of a recursive call on part of the data (these come later in the book). You can see the term defined at the top of Section 6.5, with an example of a template.

BTW, the idea of writing these templates out explicitly is central to the HtDP approach, especially when it comes to recursive functions later -- where it makes it easy to write recursive definitions almost mechanically once you have a good analysis of the data.

Eli Barzilay
Ah, that'll be it! I was obviously charging ahead too quickly and missed that bit. Thanks.
Greg Beech