The words Under construction in black text on a yellow background with diagonal black stipes surrounding it
I'm in the process of moving my site. It's still a work in progress. Please excuse the mess and broken links.

Reverse A List In Lua

TODO: Pull subtitle into page object
Code
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
bravo
delta
echo
alfa

Notes

Debugging Stuff

I'm moving stuff around right now. All this below is helping me figure out where to put stuff

        -- title

Reverse A List In Lua

-- code
-- 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/

bravo
delta
echo
alfa

-- /results


-- notes

- 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


-- categories
-- Lua 

-- metadata
-- date: 2023-10-25 15:11:29
-- id: 2xggz3la
-- site: aws
-- type: post
-- status: published