Consider the following lines: 'x' is defined as a list and then the same
symbol 'x' is used for an array:
(%i1) x:[1,2,3,4];
(%o1) [1, 2, 3, 4]
(%i2) array(x,7);
(%o2) x
Is x bound to a list or to an array ? The answer is a little surprising...
(%i3) x;
(%o3) [1, 2, 3, 4]
(%i4) listp(x);
(%o4) true
(%i5) listarray(x);
listarray: argument must be an array; found: [1, 2, 3, 4]
-- an error. To debug this try: debugmode(true);
Therefore x still represents a list. Or not ?
(%i6) x[2];
(%o6) x
2
(%i7) x[2]:2222;
(%o7) 2222
(%i8) x;
(%o8) [1, 2, 3, 4]
If you try defining the array before the list, you find that REGARDLESS
of which one among list or array was defined first:
- x is always bound to the list,
- x[j] always represents the elements of the array (but "of course" x[j]
represents elements of a list 'x' if no array 'x' is defined),
- part(x,j) always represents the elements of the list.
Ok then, some (kind of) logic is followed, but why Maxima just doesn't
sweep out the previous definition of 'x' ? Wouldn't it be much clearer ?
Best regards.
Mario