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 is still A disappearing.
procedure insertion_X_on_place_Y (Before_X, Before_Y: in t_List) is
A: constant t_List := Before_X.next;
Y: constant t_List := Before_Y.next;
Begin
Before_X.next := Before_X.next.next;
X.next := Y;
Before_Y.next := 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 := 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 := 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 := 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 := List;
while ITERATOR /= null loop
Put(ITERATOR.value'Image & ' ');
ITERATOR := ITERATOR.next;
end loop;
'1'
'3'
'4'
'5'
PLEASE HELP.