lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


>> 
>> Wrap the function and let it capture itself as an upvalue. For example;
>> 
>> do
>> local X = function(...)
> doesn't work
>>     X(...)
>> end
>> someglobal = X
>> end
>> 
>> No need for any syntactic sugar
>> 
> 


I meant this of course…

do
	local function X(i)
		if i == 1 then return 1 end
		return X(i - 1) * i
	end
	fact = X
end
print(fact(3))

—Tim