# [Maxima] Labelled indices on arrays

maxima at peutch.e4ward.com maxima at peutch.e4ward.com
Thu May 3 08:45:53 CDT 2012

```Je la 03/05/2012 14:26, andre maute skribis:
>> What I would like to do is something like being able to assign:
>>     variable['a]['x] : 1;
>>     variable['a]['y] : 33;
>>
>> and so on. But i get an error (assignment: cannot assign to
>> (variable['a])['x]).
>> In other words, I would like to create arrays the indices of which are
>> actually letters, not numbers.

> Why can't you use something like
>
> (%i1) display2d : false;
> (%o1) false
> (%i2) a : makelist(concat(a_,k),k,1,7);
> (%o2) [a_1,a_2,a_3,a_4,a_5,a_6,a_7]
>
> Andre

Hi Andre,
Actually, my state space is more than 2x2, it's four by four. What I'd l
ike to do ultimately is to do loops that will define a lot of other
arrays with the same indices, e.g.

for state1 in [a,b,c,d] do
for state2 in [w,x,y,z] do
variable_bis[state1][state2]: 4* variable[state1][state2];
variable_ter[state1][state2]: cos(variable[state1][state2]);

(Sorry I know the loop syntax is wrong but I don't have time to check
right now.)

It would just make my life a lot easier if I didn't have to remember
what integer represented what state if I write something like
variable[1][3].

Thanks

Patrick
```