Search code examples
maxima

Fill array with variables (Maxima)


The following code is available

kol:2;
arg2:-3;
arg3:1/2;
mx0:makelist(concat(arg,i),i,2,kol+1);

which displays the result

[arg2,arg3]

Tell me, please, what needs to be changed so that the result is like this

[-3,1/2]

(i.e. the values of the variables themselves should be)


Solution

  • You can do

    kol: 2;
    arg2: -3;
    arg3: 1/2;
    mx0: makelist(concat(arg,i),i,2,kol+1), infeval;
    
                                             1
    (%o4)                              [- 3, -]
                                             2
    

    or use subscripts

    kol:2;
    arg[2]:-3;
    arg[3]:1/2;
    mx0:makelist(arg[i],i,2,kol+1);
    
                                             1
    (%o4)                              [- 3, -]
                                             2
    

    http://maxima.sourceforge.net/docs/manual/maxima_singlepage.html#IDX252

    http://maxima.sourceforge.net/docs/manual/maxima_singlepage.html#IDX105