Queue/Definition: Difference between revisions

Line 5,608:
|
{ } '''QUEUE''' ==SIZE NOT ≫ ''''EMPTY'''' STO
Line 5,622:
≫ ''''POP'''' STO
|
'''EMPTY''' ''( -- )''
Test the global variable QUEUE
'''PUSH''' ''( item -- )''
Add the item at the beginning of the list
'''POP''' ''( -- item )''
Initialize stack
Line 5,655:
1: "The"
</pre>
===Shorter POP version===
This approach might be suitable for small queue sizes only, since it uses the stack to temporarily store the whole queue.
≪ IF '''QUEUE''' SIZE THEN
'''QUEUE''' LIST→ ROLLD LAST 1 - →LIST ''''QUEUE'''' STO
ELSE "ERR_Empty" END
≫ ''''POP'''' STO
 
=={{header|Ruby}}==
1,150

edits