How you might implement the exercises

4 views
Skip to first unread message

Grant Rettke

unread,
Sep 1, 2008, 11:20:51 PM9/1/08
to Study-HTDP
Hi folks,

Here is how I implement exercises. I saw implement, because I am
concerned here with a coding detail, *not* design recipes.

DrScheme has a nice feature in the top-left side of the window
(roughly) called the "definitions dropdown". Using this dropdown you
can see all of the names you've got defined in the Interactions area.

So for example if you had entered (define x 10) in the Definitions are
then you would see an entry in there that says "x". You can leverage
to make keeping track of your exercises easier. This is what I do, I
keep all of my exercises in the same file as long as it makes sense to
do so, and as part of that before every exercise I add something like
this:

(define 2.3.2 true)

That tells me:

1. What my answer was for the exercise.
2. Whether or not it is finished.

That is how I keep all of my exercises in the same file and still have
it make sense since each exercise creates any number of definitions!

Best wishes,

Grant

mike

unread,
Sep 2, 2008, 12:10:56 AM9/2/08
to Study-HTDP
good advice Grant; I am almost finished part 1 ; but are we
going to start with the first part of the new edition?
mike

Kartik

unread,
Sep 2, 2008, 1:29:54 AM9/2/08
to study...@googlegroups.com
Interesting approach, Grant.  So basically "(define 2.3.2 true)" acts like a bookmark as well as it tells the completion status.  Right?
--
Stay away from drunk acronym - it is inabbreviated.

Geoffrey S. Knauth

unread,
Sep 2, 2008, 7:34:43 AM9/2/08
to study...@googlegroups.com
On Sep 1, 2008, at 23:20, Grant Rettke wrote:
> DrScheme has a nice feature in the top-left side of the window
> (roughly) called the "definitions dropdown". Using this dropdown you
> can see all of the names you've got defined in the Interactions area.
> [...]
> (define 2.3.2 true)

Neat. I think I would prefix the first 2 with something like ex-, to
avoid problems with definitions like:
(define 2.3 true)
(define 2 true)

In early versions of Smalltalk, it was actually possible to assign
True to the object 2, or vice versa, which caused all kinds of
interesting behavior. That isn't a problem any more, and it isn't in
DrScheme either.

Geoffrey
--
Geoffrey S. Knauth | http://knauth.org/gsk

Grant Rettke

unread,
Sep 2, 2008, 8:12:28 AM9/2/08
to Study-HTDP
Hi Mike,

On Sep 1, 11:10 pm, mike <anesw...@mac.com> wrote:
> good advice Grant; I am almost finished part 1 ; but are we
> going to start with the first part of the new edition?

No, HTDP/2e isn't yet finished.

Grant Rettke

unread,
Sep 2, 2008, 8:13:00 AM9/2/08
to Study-HTDP
Hi Kartik,

On Sep 2, 12:29 am, Kartik <krind...@gmail.com> wrote:
> Interesting approach, Grant.  So basically "(define 2.3.2 true)" acts like a
> bookmark as well as it tells the completion status.  Right?

Yes and yes.

Grant Rettke

unread,
Sep 2, 2008, 8:16:10 AM9/2/08
to Study-HTDP
Hi Geoff,

On Sep 2, 6:34 am, "Geoffrey S. Knauth" <ge...@knauth.org> wrote:
> Neat.  I think I would prefix the first 2 with something like ex-, to  
> avoid problems with definitions like:
> (define 2.3 true)
> (define 2 true)

Yes that would probably decrease the likelihood of trying to bind a
boolean to a number.

> In early versions of Smalltalk, it was actually possible to assign  
> True to the object 2, or vice versa, which caused all kinds of  
> interesting behavior.  That isn't a problem any more, and it isn't in  
> DrScheme either.

The last time I looked at a Smalltalk tutorial, in 2004 or so on
Squeak or Dolphin, I think that it still allowed you to bind null to
the Smalltalk interpreter itself. Needless to say, this caused
problems :).
Reply all
Reply to author
Forward
0 new messages