Labelled indices on arrays



Thanks, just what I needed!

Je la 03/05/2012 18:30, Stavros Macrakis skribis:
> var['a,'x]:1$
> 
> Longer example:
> 
> (%i1) for i in '[a,b,c,d] do for j in '[q,r,s,t] do var[i,j] : random(100);
> (%o1) done
> (%i2) listarray(var);
> (%o2) [12,2,34,85,4,91,29,85,98,3,35,65,40,26,39,20]
> (%i3) arrayinfo(var);
> (%o3)
> [hashed,2,[a,q],[a,r],[a,s],[a,t],[b,q],[b,r],[b,s],[b,t],[c,q],[c,r],[c,s],[c,t],[d,q],[d,r],[d,s],[d,t]]
> 
> On Thu, May 3, 2012 at 1:21 PM, Patrick Blanchenay
> <patrick at blanchenay.net <mailto:patrick at blanchenay.net>> wrote:
> 
>     Je la 03/05/2012 14:53, Jaime Villate skribis:
>     > On 05/03/2012 02:50 PM, Jaime Villate wrote:
>     >> On 05/03/2012 12:32 PM, maxima at peutch.e4ward.com
>     <mailto:maxima at peutch.e4ward.com> wrote:
>     >>> I would like to create variables for each of the 2x2 possible
>     states of
>     >>> my model. Along the first dimension, the state is either a or b.
>     Along
>     >>> the second: x or y.
>     >>>
>     >>> I started by creating manually:
>     >>>     variable_ax: 1;
>     >>>     variable_ay: 33;
>     >>>     variable_bx: 4;
>     >>>     variable_by: 50;
>     >>>
>     >>> 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]).
>     >> (%i2) concat('variable_,'a,'x) :: 1;
>     >> (%o2)  1
>     >> (%i3) concat('variable_,'a,'y) :: 33;
>     >> (%o3)  33
>     >> (%i4) variable_ax;
>     >> (%o4)  1
>     >> (%i5) variable_ay;
>     >> (%o5)  33
>     > I forgot to paste:
>     >
>     > (%i6) ''(concat('variable_,'a,'x));
>     > (%o8) 1
>     >
>     > Jaime
>     >
>     >
> 
>     Thanks! Does that mean that there is no solution with arrays?
>     _______________________________________________
>     Maxima mailing list
>     Maxima at math.utexas.edu <mailto:Maxima at math.utexas.edu>
>     http://www.math.utexas.edu/mailman/listinfo/maxima
> 
> 
> 
> 
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima