[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Minimizing repeatable statements with out LuaMacro
- From: Philippe Lhoste <PhiLho@...>
- Date: Mon, 20 Jun 2011 13:29:26 +0200
On 20/06/2011 06:54, PROXiCiDE wrote:
Is it possible to crunch these repeatable statements in Lua? with out the
rewrite "IF" statements etc.. maybe inside Array/Table checking etc
local ops =
{
['>'] = function (w, n) return w > n end,
['>='] = function (w, n) return w >= n end,
['<'] = function (w, n) return w < n end,
['<='] = function (w, n) return w <= n end,
['=='] = function (w, n) return w == n end,
}
// Very primitive test...
local exp = '<='
local what = 15
local number = 10
for k, v in pairs(ops) do
if k == exp then
local b = v(what, number)
print("Found with " .. exp)
if b then print("OK") else print("NOK") end
break
end
end
--
Philippe Lhoste
-- (near) Paris -- France
-- http://Phi.Lho.free.fr
-- -- -- -- -- -- -- -- -- -- -- -- -- --