[Maxima] List and Array indexing
rswarbrick at gmail.com
Mon May 14 16:24:26 CDT 2012
Evgeniy Maevskiy <emaevskiy at mail.ru> writes:
> Good day for all.
> There are some problems...
> Can somebody explain to me the logic of indexing?
Firstly: you have sent a reasonably aggravating message. It's a lot
easier for others on the list to respond to a message of the form "I did
A, expecting B but C happened. Why? or How can I get B instead?" Asking
such questions might make it more likely that you get responses to what
you're confused about.
Anyway, to your question. The pragmatic answer is that subscripted
expressions like x[k] get treated specially. The first example you give
is not particularly confusing. Notice that when you say x: a, you are
saying "take the list stored at x and stick a in its first element"
(remember Maxima uses 1-based indexing). The statement, x yields an
error, because you are asking for an element that doesn't exist in the
list. Similarly for x[-4/5].
In the second example, you set up a hashed array in x with your second
line. Then the following line is really odd: I didn't know that Maxima
even let the user do that. What you have done is set up a situation
where x on its own refers to the list, but x[anything] is a subscripted
Anyway, that's what happens in your "problems". Now you have to explain
what you were expecting and why you think what you get is
wrong. Although I'm pretty certain it won't make any difference in this
case, it's generally also a good idea to let us know what version of
Maxima you are using. And possibly to show input / output. That would be
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 315 bytes
Desc: not available
More information about the Maxima