How to assign a value to the i-th member of an ordered list?

71 Views Asked by At

In set theory, we can write the following notation: $\;S'=S\cup\{\text{value}\}$

Now let $\;S=(a_1,\ldots,a_n)\;$ be an ordered list of $n$ pairwise distinct elements

How to define $S'$ equals to $S$ after assigning a $\text{value}$ to the $i^\text{th}$ ordered member of $S\;$?

It will be helpful if you add a complete example to your answer.

2

There are 2 best solutions below

7
On BEST ANSWER

In set theory, we can write the following notation: $\;S'=S\cup\{value\}$

Yes, we can. However one would most often not write “value” but rather introduce a new variable or constant, e.g. $v$. Note that if $v$ was an element of $S$ that $S‘$ would be equal to $S$.

Now let $\;S=(a_1,\ldots,a_n)\;$ be an ordered list of $n$ pairwise distinct elements

This is called a $n$-tuple.

How to define $S'$ equals to $S$ after assigning a $value$ to the $i^{th}$ ordered member of $S\;$?

You defined $S$ already with $a_i$ as the $i$-th component. This is now bound to $S$. You can not reassign it.

You seem to want another $$ S’ = (a_1’, \dotsc, a_n’) $$ where $a_j’ = a_j$ for all $j \ne i$ and $a_i’= v$. Again if $v$ was equal to $a_i$ then $S‘$ would be equal to $S$.

0
On

If for example, L = (a,b,c,d) is an ordered list and the
value 3 is assigned to b (b = 3), then L = (a,3,c,d).