lua-users home
lua-l archive

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


On Tue, Oct 6, 2009 at 12:12 PM, Michael Gerbracht <smartmails@arcor.de> wrote:
> 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:
>
> example = table.dim(10,10,10)
> print(example[2][4][3])
>
> output --> 0

OK, for the 2D case we just have

function dim(n,m)
   local function set(tbl,size,val) for i = 1,size do tbl[i] = val end end

   for i = 1,n do