[plt-scheme] HtDP 17.7.1 Clarification Requested

From: dave yrueta (dyrueta at gmail.com)
Date: Sat May 24 17:26:21 EDT 2008

Hi All --
Can someone clarify the meaning of HtDP problems 17.7.1 and 17.7.2?

17.7.1 --“…represent the application of a user-defined function to an
expression such as (f ( + 1 1)) or (* 3 (g 2)).  The application
should be represented as a structure with two fields. The first field
contains the name of the function, the second one the representation
of the argument expression.”

So, if a Function Application (fa) structure is defined as --
		(make-fa nof arg-exp)
-- where nof is the name-of-the-function, and arg-exp is some Scheme
Expression(sx, defined below), what is meant by ‘the name of the

For example, when considering (f (+ 1 1)) above, if f is equivalent to
(define(f x)
	(+ x 3))

-- then is the ‘name of the function’
	1. ‘f (a symbol)
	2. (define f (make-add ‘x 3)), or
	3.  something else?

Similarly, exercise 17.7.2 asks for a Function Definition (fd)
structure, which includes the function name, a single parameter name,
and the body--
		(make-fd nof nop body)
--where nof and nop are symbols and the body is some Scheme Expression

Hence, when applied to a Function Definition structure, (define(f x(+
3 x)) would become --
(make-struct ‘f ‘x (make-add 3 ‘x))).

But what about a function which references f, such as
(define(h u)(f(* 2 u))?

If the Function Application structure is used here to replace (f(* 2
u)), how is the attribute for ‘name of the function’ defined?
1.	As a Function Definition (fd) structure (define f (make-struct ‘f
‘x (make-add 3 ‘x)))?
2.	Some other Scheme Expression (sx) , such as ‘f, or (define f(make-
add 3 ‘x))?

This problem builds on the data definition for Scheme Expressions (sx)
in exercise 14.4.1, which I defined as follows:
	A Scheme Expression (sx) is
1.	a number (n)
2.	a symbol (s)
3.	a structure for primitive ‘+ (make-add sx sx)
4.	a structure for primitive ‘* (make-mul sx sx)

Dave Yrueta

Posted on the users mailing list.