lua-users home
lua-l archive

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


i suppose you want something like this:

matrix =
{
 [1] = {1,2,3,4},
 [2] = {2,3,4,5},
 [3] = {3,4,5,6},
 [4] = {4,5,6,7},
} 

access it like this:

print(matrix[1][2])
>> 2


in short, matrix is an (array) table consisting of (array) tables
array table == table indexed by numbers only


-----Ursprüngliche Nachricht-----
Von: lua-bounces@bazar2.conectiva.com.br
[mailto:lua-bounces@bazar2.conectiva.com.br] Im Auftrag von Darius Blaszijk
Gesendet: Sonntag, 4. Februar 2007 10:52
An: Lua list
Betreff: manipulating data

In my application I have a matrix of data for which I want to use Lua to 
manipulate it. I'm planning to implement filtering functions, statistical 
functions and the like.
What I'm still struggeling with though is how to represent the data in Lua. 
Currently I'm planning to keep the data in my app and provide getters and 
setters for the data. I'm finding difficulties though to find a proper 
description of it in the PIL or refman. But afair there should be a 
possibility to do it.

So what I want to be able to do is:

data[1,2] = 1.234
print(data[1,2])  -- returns 1.234

Can someone point me to the right resources so I can start reading and 
testing myself? Or perhaps someone can give me a hint.

TIA Darius