[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: tostring(): vararg in, vararg out?
- From: Javier Guerra Giraldez <javier@...>
- Date: Thu, 30 Jun 2011 09:16:59 -0500
On Thu, Jun 30, 2011 at 4:59 AM, steve donovan
<steve.j.donovan@gmail.com> wrote:
> Easy to do efficiently in C (using Lua requires packing and unpacking)
naïve, ends-on-nil version:
function mapvar (f,a,...)
if a ~= nil then
return f(a),mapvar(f,...)
end
end
slightly better:
function mapvar (f,a,...)
if select('#',...) > 0 then
return f(a),mapvar(f,...)
else
return f(a)
end
end
--
Javier