The output window closes automatically
anmol-gh opened this issue · 2 comments
anmol-gh commented
I tried visualizing a stack with cyberbrain,here is the gif for the same.
CODE
max_size=1000
stack=[0 for i in range (max_size)]
top=0
from cyberbrain import trace
@trace
def push():
global stack,top
x=int(input('enter element to push into stack:'))
if top>=max_size:
print('cannot push.Stack is full,Overflow')
else:
stack[top]=x
top+=1
@trace
def pop():
global stack,top
if top==0:
print('Cannot pop.Stack is empty.Underflow')
else:
top-=1
@trace
def printstack():
print(stack[:top])
while True:
print('Please choose an operation')
print('1. Push')
print('2. Pop')
print('3. Print')
print('4. Exit')
choice=int(input('Enter your choice'))
if choice==4:
break
elif choice==3:
printstack()
elif choice==2:
pop()
elif choice==1:
push()
else:
print('Please give a correct input')
laike9m commented
Thanks for trying it out and providing feedbacks. As of now, you can only have one @trace decorator. This is documented here:
https://github.com/laike9m/Cyberbrain/blob/master/docs/Features.md#known-limitations
I'll make it more obvious in the readme.
laike9m commented
Fixed by noting this in readme.