[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: newbee question...
- From: Rob Kendrick (Lua) <lua@...>
- Date: Thu, 19 Oct 2000 11:13:45 +0100
In message <Pine.BSO.4.21.0010191007130.9656-100000@css.tuu.utas.edu.au> you
wrote:
> On 19 Oct 2000 KZerbe@t-online.de wrote:
>
> > > 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
> >
>
> Out of curiousity...
>
> > c={1,3} print(c[0])
> nil
> > print(c[1])
> 1
> > print(c[2])
> 3
> >
>
> Why does table indexing begin at 1 and not zero? I guess this is just a
> convention, but I've become accustomed to zero based arrays :)
Thats something I found had to get used to, but I did :)
Cheers,
--
Rob Kendrick, http://www.digital-scurf.org/
Work is the scythe of time.