comp.lang.ada
 help / color / mirror / Atom feed
* can't understand how to move a node of a linked list to another place on the same
@ 2021-02-18  1:51 Mehdi Saada
       [not found] ` <1b206764-967c-4b1b-af9c-61a0cd0750fcn@googlegroups.com>
  0 siblings, 1 reply; 9+ messages in thread
From: Mehdi Saada @ 2021-02-18  1:51 UTC (permalink / 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.

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

end of thread, other threads:[~2021-02-19 18:56 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-18  1:51 can't understand how to move a node of a linked list to another place on the same Mehdi Saada
     [not found] ` <1b206764-967c-4b1b-af9c-61a0cd0750fcn@googlegroups.com>
2021-02-18  7:06   ` 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

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