From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: * X-Spam-Status: No, score=1.5 required=3.0 tests=BAYES_50,FREEMAIL_FROM, FROM_STARTS_WITH_NUMS autolearn=no autolearn_force=no version=3.4.5-pre1 X-Received: by 2002:a05:620a:135c:: with SMTP id c28mr3790640qkl.441.1613652892278; Thu, 18 Feb 2021 04:54:52 -0800 (PST) X-Received: by 2002:a25:b906:: with SMTP id x6mr5893220ybj.504.1613652892027; Thu, 18 Feb 2021 04:54:52 -0800 (PST) Path: eternal-september.org!reader02.eternal-september.org!aioe.org!news.dns-netz.com!news.freedyn.net!newsreader4.netcologne.de!news.netcologne.de!peer04.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 18 Feb 2021 04:54:51 -0800 (PST) In-Reply-To: <84c3e8ee-e4e9-4402-8da6-e43a44eca66bn@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: google-groups.googlegroups.com; posting-host=82.154.189.75; posting-account=rhqvKAoAAABpikMmPHJSZh4400BboHwT NNTP-Posting-Host: 82.154.189.75 References: <1b206764-967c-4b1b-af9c-61a0cd0750fcn@googlegroups.com> <84c3e8ee-e4e9-4402-8da6-e43a44eca66bn@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: can't understand how to move a node of a linked list to another place on the same From: Mehdi Saada <00120260a@gmail.com> Injection-Date: Thu, 18 Feb 2021 12:54:52 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Received-Bytes: 3406 Xref: reader02.eternal-september.org comp.lang.ada:61374 List-Id: Le jeudi 18 f=C3=A9vrier 2021 =C3=A0 08:06:57 UTC+1, gautier...@hotmail.com= a =C3=A9crit=C2=A0: > > No, I'll run it on paper first, please don't bother yet. > That's actually the fun part with linked lists. =20 > That's actually the fun part with linked lists.=20 I hate that to no end. I did put up quite the effort so non-ashamedly I beg for help. Here's it running on paper. Of course it's wrong 'cause the actual result i= s still A disappearing. procedure insertion_X_on_place_Y (Before_X, Before_Y: in t_List) is A: constant t_List :=3D Before_X.next; Y: constant t_List :=3D Before_Y.next; Begin Before_X.next :=3D Before_X.next.next; X.next :=3D Y; Before_Y.next :=3D X; end insertion_X_on_place_Y; Before running: X (x)->(x+1)->.. Y (y)->(y+1)->.. Before_X (x-1)->(x)->(x+1)...->(Y-1)->(Y)->(y+1).. Before_X.next (x)->(x+1)...->(Y-1)->(Y)->(y+1).. Before_Y (Y-1)->(Y)->(y+1).. Before_Y.next (Y)->(y+1).. But: I want (x-1)->(x+1)...->(Y-1)->(x)-> (Y)->(y+1).. Before_X.next :=3D X.next; X (x)->(x+1)->.. Y (y)->(y+1)->.. Before_X (x-1)-> (x+1)...->(Y-1)->(Y)->(y+1).. Before_X.next (x+1)...->(Y-1)->(Y)->(y+1).. Before_Y (Y-1)->(Y)->(y+1).. Before_Y.next (Y)->(y+1).. X.next :=3D Y; X (x)->(y)->(y+1)->.. Y (y)->(y+1)->.. Before_X (x-1)-> (x+1)...->(Y-1)->(Y)->(y+1).. Before_X.next (x+1)...->(Y-1)->(Y)->(y+1).. Before_Y (Y-1)->(Y)->(y+1).. Before_Y.next (Y)->(y+1).. Before_Y.next :=3D X; X (x)->(y)->(y+1)->.. Y (y)->(y+1)->.. Before_X (x-1)-> (x+1)...->(Y-1)->(x)->(y)->(y+1)->.. Before_X.next (x+1)...->(Y-1)->(x)->(y)->(y+1)->.. Before_Y (Y-1)->(x)->(y)->(y+1)->.. Before_Y.next (x)->(y)->(y+1)->.. It SHOULD be ok. then I display it: insertion_A_on_place_b(List, List.next); ITERATOR :=3D List; while ITERATOR /=3D null loop Put(ITERATOR.value'Image & ' '); ITERATOR :=3D ITERATOR.next; end loop; '1'=20 '3'=20 '4'=20 '5'=20 PLEASE HELP.