lua-users home
lua-l archive

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


Hi,
I'm new to Lua  but I think I like it.
Here is my question: 
How can I implement a USER-friendly method to work with 2-dimensional
arrays/matrices. (i.e. create, redim, access elements etc.)? 
I'd like to allow my users to do something like:
arrayA = array(NumCols, NumRows)   --create array
numberB = getval(arrayA, Col, Pos)    --access elements
redim(arrayA, ColDelta, RowDelta)   --realloc
arrayC = arrayA     -- copy whole array
arrayD = arrayA+arrayB   --arithmetic operators

Do I have to use the USERDATA tag for arrayA, arrayB ..., or can I do all
this with tables?

Thanks,
Chris