Previous Up Next

6.3.7  Modifying the elements of a list

The subsop command can be used to modify elements in a list.

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:

subsop([0,1,2],1=5)

or:

L:=[0,1,2];L[1]:=5
     

0,5,2
          

Input in Xcas mode, the index of the first element is 0:

subsop([0,1,2],'1=NULL')
     

0,2
          

Input in MuPAD or TI mode, the index of the first element is 1:

subsop([0,1,2],2=5)

or:

L:=[0,1,2];L[2]:=5
     

0,5,2
          

When using := to insert an element in a list, the list will be padded with zeros if necessary.

L:=[]

then:

L[3]:=5
     

0,0,0,5
          

In Maple mode the arguments are permuted and the index of the first element is 1.

subsop(2=5,[0,1,2])

or:

L:=[0,1,2];L[2]:=5
     

0,5,2 
          

Previous Up Next