# [plt-scheme] Another request for help with book (HTDP)

 From: Robby Findler (robby at cs.uchicago.edu) Date: Mon Jul 12 11:16:11 EDT 2004 Previous message: [plt-scheme] Peculiar pause with MzScheme Next message: [plt-scheme] Another request for help with book (HTDP) Messages sorted by: [date] [thread] [subject] [author]

```The code below is wrong and the sample solutions are correct. According
to the problem spec in 11.2.2, tabulate-f

"consumes a natural number n and produces a list of n posns"

Running your program for 0 will produce a list of 1 posn, but it should
produce a list of 0 posns.

I don't see any problems with 11.4.6 either.

Robby

At Sat, 10 Jul 2004 09:34:48 +0800, "Zhu Chongkai" wrote:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
>
> My answer to exercise 11.2.2 is
>
> (define (tabulate-f n)
>   (cond
>     [(zero? n) (cons (make-posn 0 (f 0)) empty)]
>     [else (cons (make-posn n (f n))
>                 (tabulate-f (sub1 n)))]))
>
> But this means that:
>
> 1 HTDP exercise 11.4.6 should better be revised, using the same f of
>   exercise 11.2.2
> 2 the official solutions (www.htdp.org/2003-09-26/Solutions/)
>   for these exercise are also wrong !!!!!!!
>
>
> ======= 2004-07-08 11:12:21 Matt H?=======
>
> >Thanks again for helping me.
> >
> >I'm working in Chapter 11 of HTDP, and for exercise 11.2.2 I came up
> >with this solution:
> >;; tabulate-f : number -> list-of-posns
> >;; product a list of n posns using f.
> >(define (tabulate-f n)
> >  (cond
> >    [(zero? n) empty]
> >    [else (cons (make-posn n (f n)) (tabulate-f (sub1 n)))]))
> >
> >Now, I'm not positive that this is correct because in exercise 11.4.6
> >it says that (tabulate-f 3) should produce:
> >(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))))
> >
> >But I get:
> >(cons (make-posn 3 8)
> >  (cons (make-posn 2 -1)
> >    (cons (make-posn 1 -4) empty)))
> >
> >Is my solution for exercise 11.2.2 incorrect?
> >
> >Thank you for your time.
> >
> >On Wed, 7 Jul 2004 15:53:46 +0800, Zhu Chongkai <mathematica at citiz.net> wrote:
> >>
> >> It is me again.
> >>
> >> Send details to my mailbox.
> >>
> >> ======= 2004-07-07 08:31:25 Matt H?=======
> >>
> >> >  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> >>
> >>
> >> >
> >> >Once again, I appear to be stuck. If someone is willing to help me
> >> >with execise 11.2.2, I would be grateful.
> >> >
> >> >Thanks.
> >> >
> >>
> >> = = = = = = = = = = = = = = = = = = = =
> >>
> >> Zhu Chongkai
> >> http://www.websamba.com/mrmathematica
> >>
> >>
>
> = = = = = = = = = = = = = = = = = = = =
>
> Zhu Chongkai
> http://www.websamba.com/mrmathematica

```

 Posted on the users mailing list. Previous message: [plt-scheme] Peculiar pause with MzScheme Next message: [plt-scheme] Another request for help with book (HTDP) Messages sorted by: [date] [thread] [subject] [author]