problem with "concatting variables"



Christian,

Thanks for the explanation.  It's a pity that our documentation didn't make
it clearer that Maxima supports subscripted variables, just like most other
programming languages.  Maxima subscripted variables can be strictly
symbolic (without a value), e.g.

          sum(a[mod(i,3)],i,0,10) => 3*d[2]+4*d[1]+4*d[0]

or be assigned values:

          for i thru 10 do x[i]:i^3$
          x[5] => 125

They can of course be assigned *symbolic* values as well:

          for i thru 10 do y[i]: trigexpand(sin(x+%pi*i/3))$
          y[4] => -sin(x)/2-sqrt(3)*cos(x)/2

Maxima can also subscript list values:

         ll: [3,1,4,1,5]$
         ll[3] => 4
         ll[1] : -7$
         ll => [-7,1,4,1,5]

Things get more complicated with declared arrays, which I recommend you
avoid for now.

I hope this helps.

              -s



On Wed, Sep 25, 2013 at 4:41 PM, Christian Stengg
<christian.stengg at gmx.at>wrote:

>  Thanks for your help. I am a maxima-autodidact and I am using Maxima a
> lot in my daily work as a teacher. I looked for a way to create variables
> (respectively names of variables) "dynamically" and learned about concat in
> the reference guide and about ''(...) by trial and error. I did not know of
> a[i] so far.
>
> Christian
>
> Am 25.09.2013 13:16, schrieb Stavros Macrakis:
>
> ''(...) Is *read-time* substitution, a very special-purpose mechanism.
> Try ev(...).
>
> But why are you creating variables in this strange way in the first place?
> Why not use a[i]?
>
> Also, how did you learn about ''(...) and concat? I wonder if there's some
> documentation or tutorial that's miseducating people... we see this problem
> often.
>
>       -s
> On Sep 25, 2013 5:21 AM, "Christian Stengg" <christian.stengg at gmx.at>
> wrote:
>
>> Hello,
>>
>> why do I get the output bj in the loop?
>>
>> Thanks for any help,
>> Christian
>>
>>
>> i:1;
>> concat(a,i)::10*i;
>> ''(concat(a,i));
>> print(''(concat(a,i)));
>>
>> for j:1 thru 2 do (
>>     concat(b,j)::10*j,
>>     print(''(concat(b,j)))
>> );
>>
>> b1;
>> b2;
>>
>>
>> (%o1) 1
>> (%o2) 10
>> (%o3) 10
>> 10
>> (%o4) 10
>> bj
>> bj
>> (%o5) done
>> (%o6) 10
>> (%o7) 20
>> _______________________________________________
>> Maxima mailing list
>> Maxima at math.utexas.edu
>> http://www.math.utexas.edu/mailman/listinfo/maxima
>>
>  E-Mail ist virenfrei.
> Von AVG ?berpr?ft - www.avg.de
> Version: 2013.0.3408 / Virendatenbank: 3222/6696 - Ausgabedatum:
> 24.09.2013
>
>
>