Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,15 @@
type
pCharNode = ^CharNode;
CharNode = record
data: char;
next: pCharNode;
end;
(* This procedure inserts a node (newnode) directly after another node which is assumed to already be in a list.
It does not allocate a new node, but takes an already allocated node, thus allowing to use it (together with
a procedure to remove a node from a list) for splicing a node from one list to another. *)
procedure InsertAfter(listnode, newnode: pCharNode);
begin
newnode^.next := listnode^.next;
listnode^.next := newnode;
end;

View file

@ -0,0 +1,27 @@
var
A, B: pCharNode;
begin
(* build the two-component list A->C manually *)
new(A);
A^.data := 'A';
new(A^.next);
A^.next^.data := 'C';
A^.next^.next := nil;
(* create the node to be inserted. The initialization of B^.next isn't strictly necessary
(it gets overwritten anyway), but it's good style not to leave any values undefined. *)
new(B);
node^.data := 'B';
node^.next := nil;
(* call the above procedure to insert node B after node A *)
InsertAfter(A, B);
(* delete the list *)
while A <> nil do
begin
B := A;
A := A^.next;
dispose(B);
end
end.