comp.lang.ada
 help / color / mirror / Atom feed
* Linked list problem
@ 1997-02-15  0:00 Blake C Weston
  1997-02-15  0:00 ` Bob Klungle
  1997-02-18  0:00 ` David Wheeler
  0 siblings, 2 replies; 4+ messages in thread
From: Blake C Weston @ 1997-02-15  0:00 UTC (permalink / raw)



I have a slight problem. I have been trying to append one linked list to
another. Unfortunately try as I might, I cannot get the algorithm to
work correctly.

As far as I understand, the method by which you append lists is to
simply make the last node of the list you are appending to 'point' to
the first node of the other list.

Can anyone advise me on this problem?

Cheers
-- 
Blake C Weston

Turnpike evaluation. For information, see http://www.turnpike.com/




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Linked list problem
  1997-02-15  0:00 Linked list problem Blake C Weston
@ 1997-02-15  0:00 ` Bob Klungle
  1997-02-18  0:00 ` David Wheeler
  1 sibling, 0 replies; 4+ messages in thread
From: Bob Klungle @ 1997-02-15  0:00 UTC (permalink / raw)



What you said is true. Not enough info to say anything else.

cheers..bob

> I have a slight problem. I have been trying to append one linked list to
> another. Unfortunately try as I might, I cannot get the algorithm to
> work correctly.
> 
> As far as I understand, the method by which you append lists is to
> simply make the last node of the list you are appending to 'point' to
> the first node of the other list.
> 
> Can anyone advise me on this problem?





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Linked list problem
  1997-02-15  0:00 Linked list problem Blake C Weston
  1997-02-15  0:00 ` Bob Klungle
@ 1997-02-18  0:00 ` David Wheeler
  1997-02-19  0:00   ` Arthur Schwarz
  1 sibling, 1 reply; 4+ messages in thread
From: David Wheeler @ 1997-02-18  0:00 UTC (permalink / raw)



Blake C Weston (blake@dedlock.demon.co.uk) wrote:
: I have a slight problem. I have been trying to append one linked list to
: another. Unfortunately try as I might, I cannot get the algorithm to
: work correctly.

: As far as I understand, the method by which you append lists is to
: simply make the last node of the list you are appending to 'point' to
: the first node of the other list.

Correct.

You can learn more about how to access types from lesson 12 of Lovelace,
an Ada95 tutorial.  You can go directly to lesson 12 by using
a web browser to open:
 http://www.adahome.com/Tutorials/Lovelace/lesson12.htm

You can start at the beginning of Lovelace by opening:
 http://www.adahome.com/Tutorials/Lovelace/lovelace.htm

A book version of the Lovelace tutorial will soon be available,
probably by the end of March 1997.
The book version will have a number of errors removed and will be
easier to read (useful if you plan to read all of it).


--- David A. Wheeler
    dwheeler@ida.org





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Linked list problem
  1997-02-18  0:00 ` David Wheeler
@ 1997-02-19  0:00   ` Arthur Schwarz
  0 siblings, 0 replies; 4+ messages in thread
From: Arthur Schwarz @ 1997-02-19  0:00 UTC (permalink / raw)
  To: dwheeler


Dave;

   The correct answer depends on the list characteristics. 

   [1] If you have a singly linked list whose last element is a pointer
to NULL
       then something like:

          new.pointer  := NULL;
          last.pointer := new;

       or more generally:

         new.pointer   := last.pointer;
         last.pointer  := new;

       should work.

   [2] If you have a singly linked list with a list with a header, then
       a. if the list is above and the header points to the first and
last
          element, the header has to be altered.
       b. If the last element on the list points to the first element on
          the list and the header points to the first and last element, 
          see (a).
       c. If the last element of the list points to the list header, and
          the list header points to the first and last element of the
          list, then see (a).

   (in general) etc., etc., ...

   And if you do have a list header, make sure that that an insertion
into
   the list recognizes that the insertion may be to an empty list.

   And if you don't have a list header, just an initial pointer to the
first
   element of a list, make sure (as above) that you care for inserting a
new
   list element to an empty list.

   (Sorry about my Ada!)

   I hope some of this helps! 

art schwarz

David Wheeler wrote:
> 
> Blake C Weston (blake@dedlock.demon.co.uk) wrote:
> : I have a slight problem. I have been trying to append one linked list to
> : another. Unfortunately try as I might, I cannot get the algorithm to
> : work correctly.
> 
> : As far as I understand, the method by which you append lists is to
> : simply make the last node of the list you are appending to 'point' to
> : the first node of the other list.
> 
> Correct.
> 
> You can learn more about how to access types from lesson 12 of Lovelace,
> an Ada95 tutorial.  You can go directly to lesson 12 by using
> a web browser to open:
>  http://www.adahome.com/Tutorials/Lovelace/lesson12.htm
> 
> You can start at the beginning of Lovelace by opening:
>  http://www.adahome.com/Tutorials/Lovelace/lovelace.htm
> 
> A book version of the Lovelace tutorial will soon be available,
> probably by the end of March 1997.
> The book version will have a number of errors removed and will be
> easier to read (useful if you plan to read all of it).
> 
> --- David A. Wheeler
>     dwheeler@ida.org




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1997-02-19  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-02-15  0:00 Linked list problem Blake C Weston
1997-02-15  0:00 ` Bob Klungle
1997-02-18  0:00 ` David Wheeler
1997-02-19  0:00   ` Arthur Schwarz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox