[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: manipulating data
- From: "Darius Blaszijk" <dhkblaszyk@...>
- Date: Sun, 4 Feb 2007 12:23:48 +0100
I understand what you mean. The problem however is that I don't want to
store the same data as table in the lua state and in my application as
object (for memory and debugging reasons). Therefore I was thinking of using
a getter and setter function that encapsulates the data. So in effect:
data[1,2] = 1.234 is comparable in calling the function setdata(1,2,1.234)
and print(data[1,2] is comparable to calling the function getdata(1,2)
the first does not return any value, the second returns the value of the
data object in my app at position 1,2
Darius
----- Original Message -----
From: "steffenj" <steffenj@arcor.de>
To: "'Lua list'" <lua@bazar2.conectiva.com.br>
Sent: Sunday, February 04, 2007 12:06 PM
Subject: AW: manipulating data
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