[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: select("#", ...) idiom
- From: Michael Roth <mroth@...>
- Date: Fri, 16 Sep 2005 00:58:34 +0200
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Rici Lake wrote:
> In any event, there are few use cases for finding the argument count which
> do not involve iterating over the arguments; I would far rather have:
>
> for i, arg in ieach(...) do process(arg) end
Hmm, could not be written with the ... operator but a table (classic
'arg' style) must be created:
function ieach(...)
local function f(arg, index)
if index < arg.n then
index = index + 1
return index, arg[index]
end
end
return f, arg, 0
end
The above code should work with both 5.0.2 and 5.1-alpha.
cu
Michael
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFDKfyaSIrOxc3jOmoRAn+UAJ9lD5Q8g0tMuY8HfiuBJq1Zmxe7EwCgoJ8L
IuK+HS0qI/uYxc6mmAX4AcA=
=bJeV
-----END PGP SIGNATURE-----
- References:
- Re: select("#", ...) idiom, Shannon Stewman
- Re: select("#", ...) idiom, Roberto Ierusalimschy
- Re[2]: select("#", ...) idiom, Doug Currie
- Re: select("#", ...) idiom, Wim Couwenberg
- Re[2]: select("#", ...) idiom, Doug Currie
- Re: Re[2]: select("#", ...) idiom, Rici Lake