From 29952c73552487be17efeef1f0fc9aec35d2b573 Mon Sep 17 00:00:00 2001 From: Starfflame Date: Mon, 10 May 2021 01:33:12 -0500 Subject: [PATCH] remove old Stack.tl --- Stack.tl | 36 ------------------------------------ 1 file changed, 36 deletions(-) delete mode 100644 Stack.tl diff --git a/Stack.tl b/Stack.tl deleted file mode 100644 index c240f49..0000000 --- a/Stack.tl +++ /dev/null @@ -1,36 +0,0 @@ -local record Stack - contents: {any} - top: number -end -function Stack:push(val: any) - self.top = self.top + 1 - table.insert(self.contents,val) -end -function Stack:pop(): any - self.top = self.top -1 - if self.top < 0 then - error("Stack underflow") - end - return table.remove(self.contents) -end -local stack_mt = {__index = Stack} -function Stack:new(): Stack - return setmetatable({contents = {}, top = 0} as Stack, stack_mt) -end - - --- operations -function add(stack: Stack) - local a: any =stack:pop() - local b: any=stack:pop() - if a is number and b is number then - local c=a+b - stack:push(c) - else - error("invalid operands for add operation!") - end -end -function dot(stack: Stack) - print(stack:pop()) -end -