- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack.lua
More file actions
Latest commit
27 lines (21 loc) · 471 Bytes
/
Copy pathstack.lua
File metadata and controls
27 lines (21 loc) · 471 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
-- Think of this data structure like a stack of paper
-- can put on the top of the stack,
-- then take it off the top
---@classStack
localstack= {}
stack.__index=stack
stack.__extVersion="0.0.3"
---@returnStack
functionstack.new(input)
returnsetmetatable(inputor {}, stack)
end
functionstack:push(input)
table.insert(self, input)
end
functionstack:pop()
returntable.remove(self, #self)
end
functionstack:peek()
returnself[#self]
end
returnstack