Queue/Usage: Difference between revisions

no edit summary
m (→‎{{header|REXX}}: added/changed comments, statements, and whitespace, used a template for the output section.)
No edit summary
Line 2,563:
3
</pre>
 
=={{header|Yabasic}}==
<lang Yabasic>stack$ = ""
 
sub push(x$)
stack$ = stack$ + x$ + "#"
end sub
 
sub pop$()
local i, r$
if stack$ <> "" then
i = instr(stack$, "#")
if i then
r$ = left$(stack$, i-1)
stack$ = right$(stack$, len(stack$) - i)
else
r$ = stack$
stack$ = ""
end if
return r$
else
print "--Queue is empty--"
end if
end sub
 
sub empty()
return stack$ = ""
end sub
 
// ======== test ========
 
for n = 3 to 5
print "Push ", n : push(str$(n))
next
 
print "Pop ", pop$()
 
print "Push ", 6 : push(str$(6))
 
while(not empty())
print "Pop ", pop$()
wend
 
print "Pop ", pop$()</lang>
 
{{out}}
<pre>Push 3
Push 4
Push 5
Pop 3
Push 6
Pop 4
Pop 5
Pop 6
Pop --Queue is empty--</pre>
 
=={{header|zkl}}==
672

edits