Advertisement
neo34rd

stack.lua

Apr 19th, 2019
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. function newStack()
  2. local _stack = {}
  3. _stack['count'] = 0
  4. return _stack
  5. end
  6.  
  7. function push(_stack, value)
  8. _stack.count = _stack.count + 1
  9. _stack[_stack.count] = value
  10. end
  11.  
  12. function pop(_stack)
  13. local value = _stack[_stack.count]
  14. _stack.count = _stack.count - 1
  15. return value
  16. end
  17.  
  18. function size(_stack)
  19. return _stack.count
  20. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement