Home
Head's Up: I'm in the middle of upgrading my site. Most things are in place, but there are something missing and/or broken including image alt text. Please bear with me while I'm getting things fixed.

Reverse A List In Lua

lua
local function reverse_list(source)
  local response = {}
  local counter = #source
  while counter > 0 do
    table.insert(response, source[counter])
    counter = counter - 1
  end
  return response
end

local data = { "alfa", "echo", "delta", "bravo" }
local reversed = reverse_list(data)

for _, value in ipairs(reversed) do
  print(value)
end
results start

- I haven't done much lua. Wouldn't be surprised to find a more built - in way to do this, but this gets me what I'm looking for