Queue/Definition: Difference between revisions

Content added Content deleted
No edit summary
Line 4,439: Line 4,439:
3
3
</pre>
</pre>

=={{header|Yabasic}}==
<lang Yabasic>limit = 1000
dim stack(limit)

top = 0

sub push(n)
if top < limit then
top = top + 1 : stack(top) = n
else
print "stack full - ";
end if
end sub

sub pop()
if top then
top = top - 1 : return stack(top + 1)
else
print "stack empty - ";
end if
end sub

sub empty()
return not top
end sub

// ======== test ========

for n = 3 to 5
print "Push ", n : push(n)
next

print "Pop ", pop()

print "Push ", 6 : push(6)

while(not empty())
print "Pop ", pop()
wend

print "Pop ", pop()
</lang>


=={{header|zkl}}==
=={{header|zkl}}==