2023-09-28 06:31:23 +00:00
|
|
|
local function make_closure (t)
|
2023-09-25 05:23:53 +00:00
|
|
|
return function (y)
|
2023-09-28 06:31:23 +00:00
|
|
|
return t.x + y
|
2023-09-25 01:40:28 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-09-28 06:31:23 +00:00
|
|
|
local f = make_closure ({ x = 11 })
|
|
|
|
local t = {}
|
2023-09-25 06:57:57 +00:00
|
|
|
local x = f (12)
|
|
|
|
print (x)
|
|
|
|
return x
|