Transform each value in a table into a new value.

Map Numbers

map_numbers.lua
local factor = 
local output = ""

for index, value in ipairs({1, 2, 3}) do
  local mapped = value * factor
  if index > 1 then
    output = output .. ","
  end
  output = output .. mapped
end

print("factor=" .. factor)
print("output=" .. output)
local factor = 
local output = ""

for index, value in ipairs({1, 2, 3}) do
  local mapped = value * factor
  if index > 1 then
    output = output .. ","
  end
  output = output .. mapped
end

print("factor=" .. factor)
print("output=" .. output)
local factor = 
local output = ""

for index, value in ipairs({1, 2, 3}) do
  local mapped = value * factor
  if index > 1 then
    output = output .. ","
  end
  output = output .. mapped
end

print("factor=" .. factor)
print("output=" .. output)
map values Mapping applies the same transformation to every element.