Combine mapping, filtering, and reducing in one pass.

Pipeline Result

pipeline_result.lua
local bonus = 
local total = 0

for _, value in ipairs({1, 2, 3}) do
  local mapped = value + bonus
  if mapped % 2 == 0 then
    total = total + mapped
  end
end

print("bonus=" .. bonus)
print("total=" .. total)
local bonus = 
local total = 0

for _, value in ipairs({1, 2, 3}) do
  local mapped = value + bonus
  if mapped % 2 == 0 then
    total = total + mapped
  end
end

print("bonus=" .. bonus)
print("total=" .. total)
local bonus = 
local total = 0

for _, value in ipairs({1, 2, 3}) do
  local mapped = value + bonus
  if mapped % 2 == 0 then
    total = total + mapped
  end
end

print("bonus=" .. bonus)
print("total=" .. total)
pipeline result A processing pipeline can transform values, filter them, and reduce the kept values to one result.