Queue/Usage: Difference between revisions

Content added Content deleted
No edit summary
Line 2,565: Line 2,565:


=={{header|Yabasic}}==
=={{header|Yabasic}}==
<lang Yabasic>stack$ = ""
<lang Yabasic>sub push(x$)
queue$ = queue$ + x$ + "#"

sub push(x$)
stack$ = stack$ + x$ + "#"
end sub
end sub


Line 2,574: Line 2,572:
local i, r$
local i, r$
if stack$ <> "" then
if queue$ <> "" then
i = instr(stack$, "#")
i = instr(queue$, "#")
if i then
if i then
r$ = left$(stack$, i-1)
r$ = left$(queue$, i-1)
stack$ = right$(stack$, len(stack$) - i)
stack$ = right$(queue$, len(queue$) - i)
else
else
r$ = stack$
r$ = queue$
stack$ = ""
queue$ = ""
end if
end if
return r$
return r$
Line 2,590: Line 2,588:


sub empty()
sub empty()
return stack$ = ""
return queue$ = ""
end sub
end sub