Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
40
Task/Queue-Usage/PL-I/queue-usage-1.pli
Normal file
40
Task/Queue-Usage/PL-I/queue-usage-1.pli
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
test: proc options (main);
|
||||
|
||||
|
||||
/* To implement a queue. */
|
||||
define structure
|
||||
1 node,
|
||||
2 value fixed,
|
||||
2 link handle(node);
|
||||
declare (head, tail, t) handle (node);
|
||||
declare null builtin;
|
||||
declare i fixed binary;
|
||||
|
||||
head, tail = bind(:node, null:);
|
||||
|
||||
do i = 1 to 10; /* Add ten items to the tail of the queue. */
|
||||
if head = bind(:node, null:) then
|
||||
do;
|
||||
head,tail = new(:node:);
|
||||
get list (head => value);
|
||||
put skip list (head => value);
|
||||
head => link = bind(:node, null:); /* A NULL link */
|
||||
end;
|
||||
else
|
||||
do;
|
||||
t = new(:node:);
|
||||
tail => link = t; /* Point the tail to the new node. */
|
||||
tail = t;
|
||||
tail => link = bind(:node, null:); /* Set the tail link to NULL */
|
||||
get list (tail => value) copy;
|
||||
put skip list (tail => value);
|
||||
end;
|
||||
end;
|
||||
|
||||
/* Pop all the items in the queue. */
|
||||
put skip list ('The queue has:');
|
||||
do while (head ^= bind(:node, null:));
|
||||
put skip list (head => value);
|
||||
head = head => link;
|
||||
end;
|
||||
end test;
|
||||
21
Task/Queue-Usage/PL-I/queue-usage-2.pli
Normal file
21
Task/Queue-Usage/PL-I/queue-usage-2.pli
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
1
|
||||
3
|
||||
5
|
||||
7
|
||||
9
|
||||
11
|
||||
13
|
||||
15
|
||||
17
|
||||
19
|
||||
The queue has:
|
||||
1
|
||||
3
|
||||
5
|
||||
7
|
||||
9
|
||||
11
|
||||
13
|
||||
15
|
||||
17
|
||||
19
|
||||
Loading…
Add table
Add a link
Reference in a new issue