comp.lang.ada
 help / color / mirror / Atom feed
From: Mehdi Saada <00120260a@gmail.com>
Subject: can't understand how to move a node of a linked list to another place on the same
Date: Wed, 17 Feb 2021 17:51:49 -0800 (PST)	[thread overview]
Message-ID: <fe533430-6f7c-4f41-a202-0251d5ca46a4n@googlegroups.com> (raw)

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.

             reply	other threads:[~2021-02-18  1:51 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-18  1:51 Mehdi Saada [this message]
     [not found] ` <1b206764-967c-4b1b-af9c-61a0cd0750fcn@googlegroups.com>
2021-02-18  7:06   ` can't understand how to move a node of a linked list to another place on the same Gautier write-only address
2021-02-18 12:54     ` Mehdi Saada
2021-02-18 15:09       ` Jeffrey R. Carter
2021-02-18 20:56       ` Simon Wright
2021-02-18 22:38         ` Mehdi Saada
2021-02-19  9:09           ` Simon Wright
2021-02-19 14:13             ` Mehdi Saada
2021-02-19 18:56             ` 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