Baseline: tree as shared
This commit is contained in:
commit
659c03bbf8
1471 files changed
+990535
No files matched your search
@@ -0,0 +1,33 @@
|
||||
# probe: a struct wrapping a List with mut methods and an Optional result
|
||||
# status: the expected output is Programming+'s interpreter's prediction; corpus.py verify confirms or refutes it on godbolt
|
||||
# expect-stdout: size 3
|
||||
# expect-stdout: 15 8 1
|
||||
# expect-stdout: None
|
||||
struct Stack(Movable):
|
||||
var items: List[Int]
|
||||
|
||||
def __init__(out self):
|
||||
self.items = List[Int]()
|
||||
|
||||
def push(mut self, x: Int):
|
||||
self.items.append(x)
|
||||
|
||||
def pop(mut self) -> Optional[Int]:
|
||||
if len(self.items) == 0:
|
||||
return None
|
||||
return self.items.pop()
|
||||
|
||||
def size(self) -> Int:
|
||||
return len(self.items)
|
||||
|
||||
|
||||
def main():
|
||||
var s = Stack()
|
||||
for x in [4, 8, 15]:
|
||||
s.push(x)
|
||||
print("size", s.size())
|
||||
var a = s.pop()
|
||||
var b = s.pop()
|
||||
print(a, b, s.size())
|
||||
_ = s.pop()
|
||||
print(s.pop())
|
||||
Reference in new issue
Block a user