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:a37:a8cc:: with SMTP id r195mr2150339qke.151.1613613109635; Wed, 17 Feb 2021 17:51:49 -0800 (PST) X-Received: by 2002:a25:57d6:: with SMTP id l205mr3113400ybb.363.1613613109397; Wed, 17 Feb 2021 17:51:49 -0800 (PST) Path: eternal-september.org!reader02.eternal-september.org!news.mixmin.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 17 Feb 2021 17:51:49 -0800 (PST) Complaints-To: groups-abuse@google.com Injection-Info: google-groups.googlegroups.com; posting-host=85.240.211.137; posting-account=rhqvKAoAAABpikMmPHJSZh4400BboHwT NNTP-Posting-Host: 85.240.211.137 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: 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 01:51:49 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader02.eternal-september.org comp.lang.ada:61368 List-Id: I cannot understand the mechanism for moving a node of a list somewhere else on the same list. the piece always just disappears. When called for two adjacent nodes, while it should have the effect of swapping them, the first just disappears. I use the pointers before said place A and B because it's a single linked list. let's have these definitions: type t_element is new Character; type t_cell; type t_List is access t_cell; type t_cell is record value: t_element; next: t_list; end record; procedure insertion_A_on_place_B (Before_A, Before_B: in t_List) is A: constant t_List := Before_A.next; B: constant t_List := Before_B.next; begin Before_A.next := Before_A.next.next; A.next := B; Before_B.next := A; end insertion_A_on_place_B; I fear I won't understand if I just read a snippet on the internet, I tried enough so that my brain just "blocks" and in that case I'll never see the issue by just trying again. Did it enough. Asperger. I know myself. I tried reading on the internet, it "blocks"... What are the correct instructions to move Element A at place B (of the same list) ? then I'll see where I block.