[plt-scheme] htdp section 17.7
Wooks-
On Jul 7, 2006, at 8:10 PM, wooks . wrote:
> Apologies if this is sent twice ...... can't remember whether I
> pressed send the first time.
>
> Please check my data analysis and examples.
My initial response: the data definitions seem close to something
that might work. There are two main points I want to make:
1.) I'm a little worried about the places where you have written, for
example:
> A multiplication is a list (* left right)
> where
> left is an expression
> right is an expression
When you say "a list (* left right)", do you mean that one constructs
such a thing by typing:
(* E1 E2)
where E1 and E2 are expressions, or by typing:
(list '* E1 E2)
where E1 and E2 are expressions, or something else entirely?
There is a very big difference between these two expressions, and to
help you remember this difference, I might recommend that you not use
lists to represent multiplications, but instead use actual
structures, e.g. of the form:
(make-felixs-mult E1 E2)
where you will have to come up with the structure definition so that
the appropriate constructor is available for you to use.
From the way you wrote your data defintions for funcInv and funcDef,
I'm not convinced you remember the right way to develop data
definitions for structured data. Go reread Section 6 of HtDP; look
at the example data defintions *carefully*.
2.) There is one important case that your examples do not cover: the
case where funcDef you are passing along has a function invocation
within its body.
That is, consider a scheme definition like:
(define (f y)
(+ 2 (g (* 3 y))))
None of your examples have a funcDef that looks like f above.
Unfortunately, its actually quite difficult to come up with an
example like the above that you could actually use in a test for
evaluate-with-one-def, because evaluate-with-one-def is specified as
taking only a single funcDef, and so there is no way to actually
evaluate an invocation of f with evaluate-with-one-def that could
correctly yield anything except an error. [[ But this will matter
when you get to 17.7.4. ]]
So, how else could we include an invocation in our function's body
for 17.7.3? Can you come up with an example of a funcDef that has an
invocation in its body that would not be an erroneous input to
evaluate-with-one-def? If so, can you anticipate any reason why
testing an invocation of such a funcDef might still pose a problem?
(This is a hard question, and there are different correct answers,
depending on how you approached section 14.4.)
-Felix