Anonymous user
Queue/Definition: Difference between revisions
m
→{{header|PureBasic}}: Corrected Pop() to handle OutOfRange-errors
(→{{header|PureBasic}}: Added PureBasic) |
m (→{{header|PureBasic}}: Corrected Pop() to handle OutOfRange-errors) |
||
Line 1,269:
Shared MyStack()
Protected n
If FirstElement(MyStack()) ; e.g. Stack not empty
n=MyStack()
DeleteElement(MyStack(),1)
Else
Debug "Pop(), out of range. Error at line "+str(#PB_Compiler_Line)
EndIf
ProcedureReturn n
EndProcedure
Line 1,289 ⟶ 1,292:
While Not Empty()
Debug Pop()
Wend
;---- Now an extra Pop(), e.g. one to many ----
Debug Pop()</lang>
'''Outputs
Line 1,296 ⟶ 1,301:
1
4
Pop(), out of range. Error at line 17
0
</tt>
|