4e78a4ef15
FossilOrigin-Name: 9cebb1e22b77545581e67fa6224286cba01a526684340452a858aa795b42af8c
24 lines
421 B
Python
24 lines
421 B
Python
class IntegerStack(list):
|
|
def __init__(self):
|
|
stack = [] * 128
|
|
self.extend(stack)
|
|
|
|
def depth(self):
|
|
return len(self)
|
|
|
|
def tos(self):
|
|
return self[-1]
|
|
|
|
def push(self, v):
|
|
self.append(v)
|
|
|
|
def dup(self):
|
|
self.append(self[-1])
|
|
|
|
def drop(self):
|
|
self.pop()
|
|
|
|
def swap(self):
|
|
a = self[-2]
|
|
self[-2] = self[-1]
|
|
self[-1] = a
|