comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: chained List manipulation without recusrsion : lost the begining of my List!
Date: 15 May 2003 06:58:01 +0100
Date: 2003-05-15T06:58:01+01:00	[thread overview]
Message-ID: <x7vfzngg39y.fsf@smaug.pushface.org> (raw)
In-Reply-To: b9uj25$bfv$1@aphrodite.grec.isp.9tel.net

"Zeg" <zeg.nospam@9online.fr> writes:

> procedure Insert_iteratif(E : in Element; L : in out Liste) is
> Aux : Liste := L;
> Z : Liste := null;

You don't need to initialize access variables, they are automatically
set to null for you

> begin
>       if (Aux = null) then
>          Aux := new Maillon'(E,null);

L was empty, so what is it pointing to now? Should you have altered it?

>       else
>          while  (Aux /= null) loop
>               if (Aux.all.valeur > E) then
>                   L := new Maillon'(E,Aux);

What has happened to all the previous elements in the list? (that L
used to be pointing to)

>                   exit;
>             elsif (Aux.all.suivant = null) then
>                   L:= new Maillon'(E,null);

What has happened to all the previous elements in the list?

>                   exit;
>             end if;
>             z := Aux ;

What is Z for? You don't read it anywhere

>             Aux := Aux.all.suivant;
>          end loop;
>      end if;
> 
> end Insert_iteratif;

It might help you to draw a picture of Maillons linked into a Liste,
and how you want a new Maillon to be linked in.



  reply	other threads:[~2003-05-15  5:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-14 23:20 chained List manipulation without recusrsion : lost the begining of my List! Zeg
2003-05-15  5:58 ` Simon Wright [this message]
2003-05-15 12:25   ` Zeg
2003-05-15 13:16   ` Zeg
2003-05-15 19:02     ` Jeffrey Carter
2003-05-16  1:11   ` Robert A Duff
2003-05-17  7:03     ` Simon Wright
replies disabled

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