lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


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.