[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Generate multidimensional tables
- From: Michael Gerbracht <smartmails@...>
- Date: Tue, 06 Oct 2009 13:35:58 +0200
Hello Jerome,
In article <89d273ba0910060340q1b43e7e3y22afa986a4290557@mail.gmail.com>,
Jerome Vuarand <jerome.vuarand@gmail.com> wrote:
> 2009/10/6 Michael Gerbracht <smartmails@arcor.de>:
> > I would like to create a multidimensional table with a lua fuction
> > containing a predefined value[1] instead of nil which should work like
> > this:
> You can do it recursively :
> function table.dim(size, ...)
> assert(type(size)=='number')
> local lastlevel = select('#', ...)==0
> local t = {}
> for i=1,size do
> if lastlevel then
> t[i] = 0
> else
> t[i] = table.dim(...)
> end
> end
> return t
> end
Thank you very much, this looks much better!
Michael