[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: RFE: table ctor syntax enhancement for many-to-one mappings
- From: Tony Finch <dot@...>
- Date: Fri, 19 Aug 2011 15:25:41 +0100
Dirk Laurie <dpl@sun.ac.za> wrote:
>
> A less trivial example of the proposed syntax extension would be:
>
> tbl = { ['a','b','c']=good, [4,5,6]=bad, [7,'8','9']=so_so }
function flatten_keys(template)
local tbl = {}
for keys,val in pairs(template) do
for i,key in ipairs(keys) do
tbl[key] = val
end
end
return kv
end
tbl = flatten_keys{ [{'a','b','c'}] = good,
[{4,5,6}] = bad,
[{7,'8','9'}] = so_so }
Tony.
--
f.anthony.n.finch <dot@dotat.at> http://dotat.at/
Lundy, Fastnet, Irish Sea: Southerly or southwesterly 5 to 7, decreasing 4 or
5 for a time. Moderate or rough. Occasional rain. Moderate or good,
occasionally poor.