Stacks

  • A stack is a LIFO structure (last in first out)
  • Example code is below

stack = nil stack = {next=stack, value = "first element on list"} stack = {next=stack, value = "second element on list"} stack = {next=stack, value = "third element on list"} stack = {next=stack, value = "fourth element on list"} root = stack while stack do print(stack.value) stack = stack.next end