# [plt-scheme] Critical Question for HTDP ex 11.4.6

 From: Nabeel Zaidi (n000_k at hotmail.com) Date: Sat Sep 1 15:52:42 EDT 2007 Previous message: [plt-scheme] The Lambda Calculus behind functional programming Next message: [plt-scheme] Critical Question for HTDP ex 11.4.6 Messages sorted by: [date] [thread] [subject] [author]

```Hello,

Regarding ex 11.4.6 in htdp, I'd like to know if the question is worded as
accurately or clearly as it could be.  It is asking the student to create a
function called (tabulate-f-up-to-20 n-below-20) with one input variable.

The problem statement says to design the function so that it tabulates
values from 0 to n.  If it is supposed to tabulate values from 0 to n, then
why is it being referred to as (tabulate-f-up-to-20)?  It should be named
(tabulate-f-up-to-n).

>From this explanation in the forum at

http://www.cs.brown.edu/pipermail/plt-scheme/2006-January/011313.html

it seems that the program should tabulate values that run up from n to 20,
not from 0 to n as the exercise in the book specifies in the very last
sentence.

-------------------------------------------------------------------------------------------------------------------------------------------
Exercise 11.4.6.   In exercises 11.2.2, 11.4.4, and 11.4.5, we developed
functions that tabulate the mathematical function f in various ranges. In
both cases, the final function produced a list of posns that was ordered in
descending order. That is, an expression like (tabulate-f 3) yields the list

(cons (make-posn 3 2.4)
(cons (make-posn 2 3.4)
(cons (make-posn 1 3.6)
(cons (make-posn 0 3.0)
empty))))

If we prefer a list of posns in ascending order, we must look at a different
data collection, natural numbers up to a certain point in the chain:

A natural number [<= 20] (N[<=20]) is either

20 or

(sub1 n) if n is a natural number [<= 20].

Of course, in high school, we refer to N[<=-1] as the negative integers.

Develop the function

;; tabulate-f-up-to-20 : N [<= 20]  ->  N
(define (tabulate-f-up-to-20 n-below-20) ...)
which tabulates the values of f for natural numbers less than 20.
Specifically, it consumes a natural number n less than or equal to 20 and
produces a list of posns, each of which has the shape (make-posn n (f n))
for some n between 0 and n (inclusively).
-------------------------------------------------------------------------------------------------------------------------------------------

Could someone please clarify specifically if:
1.  the problem is asking to tabulate values from 0 to n and expecting only
one variable input form the user
2.  the problem is asking to tabulate values form 0 to n and allowing two
variable inputs from the user (which is the case with the surrounding
problems 11.4.5 & 11.4.7)
3.  the problem is asking to tabulate values from n to 20 which
a)  is what the last explanation in the forum seems to
indicate
b)  then is easier to understand why it's asking for only one
variable input
4.  there is something I am missing or misunderstanding.

Thank you.
Nab

_________________________________________________________________
Enter to win a night a VIP night out at TIFF
http://redcarpet.sympatico.msn.ca/

```

 Posted on the users mailing list. Previous message: [plt-scheme] The Lambda Calculus behind functional programming Next message: [plt-scheme] Critical Question for HTDP ex 11.4.6 Messages sorted by: [date] [thread] [subject] [author]