Queue/Definition: Difference between revisions
→{{header|RPL}} Shorter POP version
m (→{{header|RPL}}) |
|||
Line 5,608:
|
≪
≪
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}}==
|