Queue/Definition: Difference between revisions

Content added Content deleted
Line 5,608: Line 5,608:
|
|
{ } ''''QUEUE'''' STO ≫ ''''EMPTY'''' STO
{ } '''QUEUE''' == ≫ ''''EMPTY'''' STO
'''QUEUE''' + ''''QUEUE'''' STO ≫ ''''PUSH'''' STO
'''QUEUE''' + ''''QUEUE'''' STO ≫ ''''PUSH'''' STO
IF '''QUEUE''' SIZE THEN
IF '''QUEUE''' SIZE THEN
Line 5,621: Line 5,623:
|
|
''( -- )''
''( -- )''
Store an empty list in the QUEUE variable
Test the global variable QUEUE
''( item -- )''
''( item -- )''
Add the item at the beginning of the list
Add the item at the beginning of the list
''( -- item )''
''( -- item )''
Line 5,635: Line 5,639:
{{in}}
{{in}}
<pre>
<pre>
{ } 'QUEUE' STO
'''EMPTY'''
EMPTY
"The" '''PUSH'''
7 '''PUSH'''
"The" PUSH
{ Wonders } '''PUSH'''
7 PUSH
{ Wonders } PUSH
'''QUEUE'''
QUEUE
'''POP'''
EMPTY
POP
</pre>
</pre>
{{out}}
{{out}}
<pre>
<pre>
4: 1
2: { 'Wonders' 7 "The" }
3: { 'Wonders' 7 "The" }
2: 0
1: "The"
1: "The"
</pre>
</pre>