6.3.7 Modifying the elements of a list
The subsop command
can be used to modify elements in a list.
-
subsop takes two arguments:
-
L, a list.
- i=value, an index and a new value.
- (In all but Maple mode).
subsop(L,i=value) returns the list L
with the value at index i replaced by value.
- (In Maple mode; the only difference is the order of
the arguments).
subsop(i=value,L) returns the list L
with the value at index i replaced by value.
Remark.
If the second argument is i=NULL, then
the element at index i is removed from L.
You can also redefine elements (or define new elements, but not remove
elements) with :=.
Examples
Input in Xcas mode, the index of the first element is 0:
or:
Input in Xcas mode, the index of the first element is 0:
Input in MuPAD or TI mode, the index of the first element is 1:
or:
When using := to insert an element in a list, the list will
be padded with zeros if necessary.
then:
In Maple mode the arguments are permuted and the index of
the first element is 1.
or: