Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

NEED HELP PLEASE

1 view
Skip to first unread message

sam

unread,
Jun 27, 1998, 3:00:00 AM6/27/98
to

If would please tell me what you think about the following problem:


Problem:
The primitive REVERSE copies the top-level of the list given as its
argument. Write OUR-REVERSE, a procedure that reverses a list without
copying ?

Kent M Pitman

unread,
Jun 27, 1998, 3:00:00 AM6/27/98
to

"sam" <was...@sigmaweb.net> writes:

> If would please tell me what you think about the following problem:

Sure! Glad to.

> Problem:
> The primitive REVERSE copies the top-level of the list given as its
> argument. Write OUR-REVERSE, a procedure that reverses a list without
> copying ?

What do I think about the problem? I think it's a homework problem
for a class. Not only that, but I think it's not going to teach you
anything if you get someone else to do it

And by the way, though you didn't ask, here's a piece of "extra credit"
advice to ponder:

I personally think it's a BAD idea for students to send mail to
newsgroups asking to have their homework done. You may or may not be
aware of the fact that sites like http://www.dejanews.com/ archive all
newsgroup traffic and burn it into cdrom for sale to various places.
This is the modern equivalent of etching everything you say into stone
so that it will be accessible to all future ages. Why should you or
anyone care? Well, this means that years or even decades from now,
anything you or anyone says on any newsgroup becomes part of the
permanent record that can be inspected by potential employer to see
what that person's interests, biases, etc. are. And a thing I'd
imagine they would want to know about a person but that said person
might not want them to know is that the person didn't do his/her own
homework... Seems like that could lose a job, or maybe just result in
a lower pay offer.

I might be wrong, of course. The question is whether you can afford
the risk.

Stig Hemmer

unread,
Jun 28, 1998, 3:00:00 AM6/28/98
to

"sam" <was...@sigmaweb.net> writes:
> The primitive REVERSE copies the top-level of the list given as its
> argument. Write OUR-REVERSE, a procedure that reverses a list without
> copying ?

Draw a box diagram with car and cdr pointers for a three-element list.

Draw the corresponding diagram for the reversed list. Keep the boxes
and their car pointers in the same places as the first diagram and
just move the cdr pointers.

Look at the two diagrams and see what needs to be done to get from one
to the other.

Write your function doing this.

Stig Hemmer.

PS: Are they called "first and rest pointers" these days?

Erik Naggum

unread,
Jun 28, 1998, 3:00:00 AM6/28/98
to

* Stig Hemmer

| Keep the boxes and their car pointers in the same places as the first
| diagram and just move the cdr pointers.

in the interest of being the least _directly_ helpful on this homework
assignment, isn't he better off keeping the CDRs and swapping the CARs?

| PS: Are they called "first and rest pointers" these days?

never seen these function names used to name "pointers". CAR and CDR are
still the low-level implementation details of a CONS, while FIRST and
REST refer to a particular view of the CONS, namely when used as a list.

#:Erik
--
http://www.naggum.no/spam.html is about my spam protection scheme and how
to guarantee that you reach me. in brief: if you reply to a news article
of mine, be sure to include an In-Reply-To or References header with the
message-ID of that message in it. otherwise, you need to read that page.

Scott L. Burson

unread,
Jun 28, 1998, 3:00:00 AM6/28/98
to

Erik Naggum wrote:
>
> * Stig Hemmer
> | Keep the boxes and their car pointers in the same places as the first
> | diagram and just move the cdr pointers.
>
> in the interest of being the least _directly_ helpful on this homework
> assignment, isn't he better off keeping the CDRs and swapping the CARs?

No. NREVERSE swaps the cdrs, and for good reason, as you'll see if you try
writing it both ways.

-- Scott

* * * * *

To use the email address, remove all occurrences of the letter "q".

0 new messages