SHARE
TWEET

stack.lua

neo34rd Apr 19th, 2019 (edited) 162 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top