Created
December 16, 2014 07:20
-
-
Save kylelk/adac066522d6337b2160 to your computer and use it in GitHub Desktop.
simple stack in lua
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stack = {} | |
function stack.push(item) | |
table.insert(stack, item) | |
end | |
function stack.pop() | |
return table.remove(stack) | |
end | |
s = stack | |
for i=1,10 do | |
s.push(i) | |
end | |
a = s.pop() | |
while(a) do | |
print(a) | |
a = s.pop() | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment