Re: Conditionally filling tables
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: Conditionally filling tables
- From: Adrian Sietsma <adrian_groups@...>
- Date: 2006年3月11日 01:04:05 +1100
Alexander Gladysh wrote:
I've used 'false' in such cases, as table hole fillers.
Condition1 and C or D,
Condition2 and E or false,
Simple, but not perfect..
Thanks, but 1) this still require post-processing of the table and 2)
what if I'd want to create array of bools?
local nothing = {}
t = {
(Condition1 and C) or (not Condition1 and D),
(Condition2 and E) or (not Condition2 and nothing) ,
}
...
local j = 1
for i = 1, table.maxn(t) do
local v = t[i]
if v == nil then break end
if v ~= nothing then
t[j], j = v, j+1
end
end
Adrian