[plt-scheme] HTDP Section 18 Pragmatics of local, Part 2

From: Marco Morazan (morazanm at gmail.com)
Date: Thu Apr 23 16:35:29 EDT 2009

On Thu, Apr 23, 2009 at 4:21 PM, Emeka <emekamicro at gmail.com> wrote:
> Is like I have understood the reasoning now.
> (star? A) ---- expands because of the recursive procedure A. This is what I
> figured out
> (star? (star? (star? (star? struct-star)))) When you get to struct-star ,
> that when the inner most star? becomes true and it's procedure A is called,
> which is indeed the last struct-star is the list. If its matches s, end of
> story, otherwise it propergates up. Is this my logic true?
>

Clearly, you still need to more thoroughly digest the design recipe
and the ideas behind program design. I must be honest and state that I
am not really sure what you mean above. You are, however, exhibiting
dynamic reasoning (thinking about how the program runs) instead of
static reasoning (understanding what the expressions in your function
mean).

(local ((define r (last-occurrence s (rest alostars)))) -- defines the
last occurence of a star structure in the rest of alostars that has s
in its name field if it exists. That is, it is the last star structure
in the rest of alostars that has the symbol s in its name field or it
is false (because no such star structure exists).

Ask yourself, if r is a star then is it the last occurence of a star
with name s? Where else can a star with name s be found?

Ask yourself, if r is false where, if anywhere, can there be a star with name s?

-- 

Cheers,

Marco


Posted on the users mailing list.