Kouksi44

stack

Mar 11th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.32 KB | None | 0 0
  1. return function()
  2.   local s = {
  3.     values = {};
  4.   }
  5.  
  6.   s.push = function(val)
  7.     table.insert(s.values,1,val)
  8.   end
  9.  
  10.   s.pop = function()
  11.     return table.remove(s.values,1)
  12.   end
  13.  
  14.   s.peek = function()
  15.     return s.values[1]
  16.   end
  17.  
  18.   s.empty = function()
  19.     return #s.values == 0
  20.   end
  21.   return s
  22. end
Advertisement
Add Comment
Please, Sign In to add comment