带一个参数

Lambda 表达式

-- 没有简写形式:
-- lambda 就是表达式 function(x) ... end,存放在变量中
local pow_of_two = function(power)
  return 2 ^ power
end

local pow8 = pow_of_two(8)
-- pow8 = 256.0

-- 同样的函数,用命名形式写
local function pow_of_three(power)
  return 3 ^ power
end

local pow3 = pow_of_three(3)
-- pow3 = 27.0

print("pow8 = " .. pow8)
print("pow3 = " .. pow3)