[Tutor] Table or Matrix Whatever

Tesla Coil tescoil@rtpro.net
Thu, 06 Apr 2000 08:14:20 -0500


On 6 Apr 2000, Gustavo Passos Tourinho
> I would like to know how can i creat a table or matrix.
> I need to store datas like:
>
>        1         2        3
> q1      a         b       a,b
> q2      b         a        a
>
> And how can i acess the datas from table like:
> test[2][2]=a

test[2][2] would be out of range because
indexing begins at zero.  Otherwise...
>>> a = 42
>>> b = 23
>>> test = [[a, b, [a, b]], [b, a, a]]
>>> test[0][0]
42
>>> test[0][1]
23
>>> test[0][2]
[42, 23]
>>> test[0][2][0]
42
>>> test[0][2][1]
23
>>> test[1][0]
23
>>> test[1][1]
42
>>> test[1][2]
42
>>> a=90    #Take note, we've loaded test with values
>>> test    #to which a and b point, not the pointers.
[[42, 23, [42, 23]], [23, 42, 42]]  
>>> test[0][2] = [a,b]
>>> test
[[42, 23, [90, 23]], [23, 42, 42]]
>>> test = [[a, b, [a, b]], [b, a, a]]
[[90, 23, [90, 23]], [23, 90, 90]]
 
Now that we have this much out of the way, 
someone else can elaborate on the topic...