[Maxima] List and Array indexing
villate at fe.up.pt
Wed May 16 07:59:43 CDT 2012
I think that nobody has answered your last message, so I will try to.
On 05/15/2012 02:02 PM, Evgeniy Maevskiy wrote:
> Thank you, Rupert, for your answer. About my expectations.
> First example
> 1) x is an array, because we call x[-4/5], x[-1], x, x, x[4/5], x[6/10] in
Wrong, the makelist command you used:
is equivalent to having written down:
[x[-4/5], x[-1], x, x, x[4/5], x[3/5]]
which does not create any array and does not give any values to x; x
remains an unknown variable.
> 2) after x:makelist(...) x is a list;
> 3) x is a list therefore x not exists.
> Second example
> 1) x is an array and x=a;
Correct. If there was already a list named x, the command x:... would
have replaced its first element.
Since you do not have any list named x, the command x:... created an
array x, with one element x.
> 2) after x:makelist(...) x is a list (listp=true);
Correct. The array x that you have created in 1) continues to exist, and
you have also created
a list which is also named x, as the array.
> 3) ... but x, x[-4/5], etc. are safe and sound
Wrong. The only one that is safe and sound is x, because you have
only created one element (x:a)
for the array x. x and x[-4/5] remain undefined.
Notice that you now have a confusing situation, because x might refer
to the element "1" of array x
or to the first element of the list x. Different functions in Maxima
will look first in the array or in the
list, so in some cases you get the element x of the array and in some
other cases the element x
of the list:
x ---> element 1 of the array
first(x) ---> element 1 of the list
part(x,1) ---> element 1 of the list
I hope this helps.
More information about the Maxima