comp.lang.ada
 help / color / mirror / Atom feed
* How to write a list in Ada95???
@ 2000-10-22  0:00 klhui
  2000-10-22  0:00 ` James Rogers
  0 siblings, 1 reply; 4+ messages in thread
From: klhui @ 2000-10-22  0:00 UTC (permalink / raw)


I am a new user, how can i write an integer list by using the access
type???
And also how can i print the whole list????
Thanks for reply





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

* Re: How to write a list in Ada95???
  2000-10-22  0:00 How to write a list in Ada95??? klhui
@ 2000-10-22  0:00 ` James Rogers
  2000-10-22  0:00   ` klhui
  0 siblings, 1 reply; 4+ messages in thread
From: James Rogers @ 2000-10-22  0:00 UTC (permalink / raw)


kluhi,

This looks a lot like a homework assignment.

I will point you to some examples of linked lists in Ada.

If you have access to the GNAT compiler, you will find an example
of a linked list in its "examples" directory.

If you have access to the web, you will find examples of linked
lists in the "source" section of www.adapower.com.

Jim Rogers
Colorado Springs, Colorado

klhui wrote:
> 
> I am a new user, how can i write an integer list by using the access
> type???
> And also how can i print the whole list????
> Thanks for reply




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

* Re: How to write a list in Ada95???
  2000-10-22  0:00 ` James Rogers
@ 2000-10-22  0:00   ` klhui
  2000-10-23  0:00     ` Alejandro Villanueva
  0 siblings, 1 reply; 4+ messages in thread
From: klhui @ 2000-10-22  0:00 UTC (permalink / raw)


sorry, as i have alreayd read the web page and see the example in the Gnat
compiler, i can't understand how can i print the list element........
how can i get help???
(i have define an integer list that has a pointer points to a record(The
record has an integer variables and a pointer to the next)

James Rogers wrote:

> kluhi,
>
> This looks a lot like a homework assignment.
>
> I will point you to some examples of linked lists in Ada.
>
> If you have access to the GNAT compiler, you will find an example
> of a linked list in its "examples" directory.
>
> If you have access to the web, you will find examples of linked
> lists in the "source" section of www.adapower.com.
>
> Jim Rogers
> Colorado Springs, Colorado
>
> klhui wrote:
> >
> > I am a new user, how can i write an integer list by using the access
> > type???
> > And also how can i print the whole list????
> > Thanks for reply





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

* Re: How to write a list in Ada95???
  2000-10-22  0:00   ` klhui
@ 2000-10-23  0:00     ` Alejandro Villanueva
  0 siblings, 0 replies; 4+ messages in thread
From: Alejandro Villanueva @ 2000-10-23  0:00 UTC (permalink / raw)


Excuse me again Robert, but I'll post some unchecked code here ;-)

type Cell;
type Cell_Ptr is access Cell;
type Cell is
   record
      Number: Integer;
      Next: Cell_Ptr;
   end record;

The_List: Cell_Ptr := new Cell;

procedure Fill_The_List is
   My_List: Cell_Ptr := The_List;
begin
   for I in 0 .. 20 loop
      My_List.Number := I;
      My_List.Next := new Cell;
      My_List := My_List.Next;
   end loop;
end Fill_The_List;

procedure Print_The_List is
   My_List: Cell_Ptr := The_List;
begin
   while The_List.Next /= null loop
      Ada.Text_IO.Put_Line (Integer'Image (My_List.Number));
      My_List := My_List.Next;
   end loop;
end Print_The_List;

Hope the code is right, but that's the idea ;-)



klhui wrote:

> sorry, as i have alreayd read the web page and see the example in the Gnat
> compiler, i can't understand how can i print the list element........
> how can i get help???
> (i have define an integer list that has a pointer points to a record(The
> record has an integer variables and a pointer to the next)
>
> James Rogers wrote:
>
> > kluhi,
> >
> > This looks a lot like a homework assignment.
> >
> > I will point you to some examples of linked lists in Ada.
> >
> > If you have access to the GNAT compiler, you will find an example
> > of a linked list in its "examples" directory.
> >
> > If you have access to the web, you will find examples of linked
> > lists in the "source" section of www.adapower.com.
> >
> > Jim Rogers
> > Colorado Springs, Colorado
> >
> > klhui wrote:
> > >
> > > I am a new user, how can i write an integer list by using the access
> > > type???
> > > And also how can i print the whole list????
> > > Thanks for reply

--
------------------------------------------------------
�Quieres Cobrar por Navegar en Internet?
Visita: http://www.navegana.com/dinero/flintstone.html
------------------------------------------------------
Alejandro Villanueva
190921@cepsz.unizar.es
------------------------------------------------------







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

end of thread, other threads:[~2000-10-23  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-10-22  0:00 How to write a list in Ada95??? klhui
2000-10-22  0:00 ` James Rogers
2000-10-22  0:00   ` klhui
2000-10-23  0:00     ` Alejandro Villanueva

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