![]() |
  |
|
3.6.6.1 Simple uses of Part If it is necessary to replace some element of the list with a known address with some new expression or value (say, symbol <a>), this can be done directly. Here are our lists:
Say, we now want to replace the element with the address {5} with <a>:
Now, let us now in our list <complextestlist> replace a random element in every sublist with <a>:
Notice that such modifications as described above are only possible if lists are stored in some variable (in C we would say, that it is an L-value). In particular, this input is a mistake:
Essentially, in all the above examples the Part command ([[ ]] ) was used for modification of expressions. Note also that the modification of lists with Part introduces side effect, since it is the original variable where the list is stored that is modified, not the copy of the list.
|
|||||||||||||||||