Skip to content

Instantly share code, notes, and snippets.

@nefftd
Created July 16, 2014 03:46
Show Gist options
  • Save nefftd/4109463c5473bf26a954 to your computer and use it in GitHub Desktop.
Save nefftd/4109463c5473bf26a954 to your computer and use it in GitHub Desktop.
local stack_prototype = { __index = {
MAXSIZE = 100, -- default max size (client called newstack() with no size)
push = function(self,val)
if #self > self.MAXSIZE then
table.remove(self,1)
end
self[#self+1] = val
end,
pop = function(self)
return table.remove(self)
end,
} }
function newstack(MAXSIZE)
return setmetatable({ MAXSIZE = MAXSIZE },stack_prototype)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment