Queue/Definition: Difference between revisions

Content added Content deleted
Line 5,608: Line 5,608:
|
|
{ } '''QUEUE''' == ≫ ''''EMPTY'''' STO
'''QUEUE''' SIZE NOT ≫ ''''EMPTY'''' STO
Line 5,622: Line 5,622:
≫ ''''POP'''' STO
≫ ''''POP'''' STO
|
|
''( -- )''
'''EMPTY''' ''( -- )''
Test the global variable QUEUE
Test the global variable QUEUE
''( item -- )''
'''PUSH''' ''( item -- )''
Add the item at the beginning of the list
Add the item at the beginning of the list
''( -- item )''
'''POP''' ''( -- item )''
Initialize stack
Initialize stack
Line 5,655: Line 5,655:
1: "The"
1: "The"
</pre>
</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}}==
=={{header|Ruby}}==