[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: newbee question...
- From: KZerbe@...
- Date: 19 Oct 2000 10:00 GMT
> 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?
>
Forget the unflexibility of "legacy programming languages" like maybe C
or BASIC (>>yuck<<).
You need not to "redimensioning" anything. Just add new elements- or
even dimensions. Even don't think about indexes being contigous
-A table can contain tables, so one solution for two dimensional
matrices can be a table of tables
-you don't have to specify a size ever
- to cleanup, just assign nil or leave the scope where the table
is valid, the garbage collector does the rest