Anonymous user
Queue/Definition: Difference between revisions
→{{header|REXX}}: version 2 elided. -- ~~~~
m (→version 2: undented subroutine fence. -- ~~~~) |
(→{{header|REXX}}: version 2 elided. -- ~~~~) |
||
Line 2,578:
=={{header|REXX}}==
Support for '''LIFO''' & '''FIFO''' queues is built into the [[REXX|Rexx]] language.
<br>The following are supported in REXX:
* '''PUSH''' (lifo)
* '''QUEUE''' (fifo)
* '''PULL''' --- which is a short version of:
* '''PARSE UPPER PULL'''
* '''PARSE PULL'''
* '''QUEUED()''' [a BIF which returns the number of queued entries.]
Say 'Queue is empty'▼
Say 'There are' queued() 'elements in the queue'▼
</lang>▼
'''Output:'''▼
<pre style="height: 20ex; overflow: scroll;">▼
Queue is empty▼
There are 2 elements in the queue▼
1: Fred 2▼
3: Toft 2▼
<lang rexx>/*REXX program to demonstrate FIFO queue usage by some simple operations*/
call viewQueue
Line 2,647 ⟶ 2,598:
do n=1 while queued()\==0
parse pull xxx
say "queue entry" n': ' xxx
end /*n*/
call viewQueue
Line 2,655 ⟶ 2,606:
else say 'There are' queued() 'elements in the queue'
return</lang>
▲ queue entry 1: Fred 2
queue entry 2:
▲ queue entry 3: Toft 2
queue entry 4:
▲Queue is empty
=={{header|Ruby}}==
|