Queue/Definition: Difference between revisions

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