Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
38
Task/Stack/Liberty-BASIC/stack.basic
Normal file
38
Task/Stack/Liberty-BASIC/stack.basic
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
global stack$
|
||||
stack$=""
|
||||
|
||||
randomize .51
|
||||
for i = 1 to 10
|
||||
if rnd(1)>0.5 then
|
||||
print "pop => ";pop$()
|
||||
else
|
||||
j=j+1
|
||||
s$ = chr$(j + 64)
|
||||
print "push ";s$
|
||||
call push s$
|
||||
end if
|
||||
next
|
||||
|
||||
print
|
||||
print "Clean-up"
|
||||
do
|
||||
print "pop => ";pop$()
|
||||
loop while not(empty())
|
||||
print "Stack is empty"
|
||||
|
||||
end
|
||||
|
||||
'------------------------------------
|
||||
sub push s$
|
||||
stack$=s$+"|"+stack$ 'stack
|
||||
end sub
|
||||
|
||||
function pop$()
|
||||
if stack$="" then pop$="*EMPTY*": exit function
|
||||
pop$=word$(stack$,1,"|")
|
||||
stack$=mid$(stack$,instr(stack$,"|")+1)
|
||||
end function
|
||||
|
||||
function empty()
|
||||
empty =(stack$="")
|
||||
end function
|
||||
Loading…
Add table
Add a link
Reference in a new issue