lua-users home
lua-l archive

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



John A GILBERT wrote:
Is it possible to define multidimensional arrays in Lua?

Some_array [ i, j, k,,n ] = some_value
for values of i, j, k..to n

Well, you can either put tables within tables:

  some_array[i][j][k][m][n] = 'something'

or implement your own data structure in Lua or C/C++

  some_array:ref(i,j,k,m,n) = 'something'

You can also use your own interators in for loops:

  for v in some_array:values() do ... end

Lua is pretty flexible. You can keep is simple, or you can make it fancy. We can help you with the implementation, but it helps to know a little bit about the problem you are trying to solve.

- Peter Shook