Queue/Definition: Difference between revisions
Content added Content deleted
m (→{{header|AWK}}: Handle empty queue.) |
m (→version 2: simplief the viewQueue subroutine. -- ~~~~) |
||
Line 2,638: | Line 2,638: | ||
call viewQueue |
call viewQueue |
||
a="Fred" |
a="Fred" |
||
push /*puts a "null" |
push /*puts a "null" on top of queue.*/ |
||
push a 2 /*puts "Fred 2" |
push a 2 /*puts "Fred 2" on top of queue.*/ |
||
call viewQueue |
call viewQueue |
||
queue "Toft 2" /*put "Toft 2" |
queue "Toft 2" /*put "Toft 2" on queue bottom.*/ |
||
queue /*put a "null" |
queue /*put a "null" on queue bottom.*/ |
||
call viewQueue |
call viewQueue |
||
do n=1 while queued()\==0 |
do n=1 while queued()\==0 |
||
Line 2,651: | Line 2,651: | ||
call viewQueue |
call viewQueue |
||
exit /*stick a fork in it, we're done.*/ |
exit /*stick a fork in it, we're done.*/ |
||
/*─────────────────────────────────────viewQueue subroutine─────────────*/ |
|||
/*──────────────────────────────────VIEWQUEUE subroutine────────────────*/ |
|||
viewQueue: |
viewQueue: if queued()==0 then say 'Queue is empty' |
||
⚫ | |||
if queued()==0 then say 'Queue is empty' |
|||
⚫ | |||
return</lang> |
return</lang> |
||